stianaske / pybotvac

Python module for interacting with Neato Botvac Connected vacuum robots.
MIT License
84 stars 44 forks source link

Fix invalid escape sequence #85

Closed Santobert closed 5 months ago

Santobert commented 5 months ago

With the current release home assistant logs a warning:

Logger: py.warnings Quelle: components/neato/init.py:6 Erstmals aufgetreten: 18:38:05 (1 Vorkommnisse) Zuletzt protokolliert: 18:38:05

/usr/local/lib/python3.12/site-packages/pybotvac/robot.py:141: SyntaxWarning: invalid escape sequence '\d' endpoint=re.sub(":\d+", "", endpoint), # noqa: W605, Remove port number

The fix was to declare a string explicitly as regex in robots.py, line 144:

From this:

        self._url = "{endpoint}/vendors/{vendor_name}/robots/{serial}/messages".format(
            endpoint=re.sub(":\d+", "", endpoint),  # noqa: W605, Remove port number
            vendor_name=vendor.name,
            serial=self.serial,
        )

To this:

        self._url = "{endpoint}/vendors/{vendor_name}/robots/{serial}/messages".format(
            endpoint=re.sub(r":\d+", "", endpoint),  # Remove port number
            vendor_name=vendor.name,
            serial=self.serial,
        )

Unfortunately, I had to fix some technical debt to keep the CI happy, and so this PR grew. I only did the most important things to get the CI up and running, but it would need some more maintenance, which is not included in this PR.

Santobert commented 5 months ago

@stianaske do you mind having a look :)

stianaske commented 5 months ago

LGTM! Thanks for fixing!