Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sensor.py #587

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update sensor.py #587

wants to merge 1 commit into from

Conversation

CrazyUs3r
Copy link

@CrazyUs3r CrazyUs3r commented May 18, 2024

The warning you're seeing is because Python is treating \S as an invalid escape sequence within the regular expression. In Python strings, the backslash \ is used as an escape character, so \S without a preceding r (indicating a raw string) is problematic.

To fix this, you should use a raw string for your regular expression. This way, backslashes are treated literally, not as escape characters. Here's the corrected line of code:

python

if uom and (re.match(r"\S+", uom)):

By adding the r before the string, it tells Python to treat the backslashes as literal characters. This should resolve the SyntaxWarning.

@githubDante
Copy link

If you add Closes #559 in the description the issue will be closed automatically if/when this is merged 😉

@sofkaski
Copy link

sofkaski commented Jun 24, 2024

If you add Closes #559 in the description the issue will be closed automatically if/when this is merged 😉

You could do this for example in this way in the commit message:

Fix regexp definition in sensor.py

Closes #559.

In general commit messages should be more descriptive. E.g. if you use git log --oneline it is nice to get already some hint what the change is about. Then in the body of the commit message you can tell more what has been changed and why. In this case link to the issue is likely enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants