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

Use raw literals for regex patterns #96

Merged
merged 1 commit into from
Aug 2, 2019

Conversation

dwolfi
Copy link
Contributor

@dwolfi dwolfi commented Jul 26, 2019

Should fix this Python 3 related warning:

 src/bleak/bleak/backends/bluezdbus/utils.py:10: DeprecationWarning: invalid escape sequence \d
    _hci_device_regex = re.compile("^hci(\d+)$")

@dwolfi dwolfi closed this Jul 26, 2019
@dwolfi dwolfi reopened this Jul 26, 2019
Copy link
Owner

@hbldh hbldh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change and I will merge

@@ -6,8 +6,8 @@
from bleak.backends.bluezdbus import defs
from bleak.exc import BleakError

_mac_address_regex = re.compile("^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$")
_hci_device_regex = re.compile("^hci(\d+)$")
_mac_address_regex = re.compile(r'^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This row does not need to be changed. The code formatter black, which I use for bleak, will change your single quotes to doubles very soon. The string also does not need to be binary. I.e. Remove this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

_mac_address_regex = re.compile("^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$")
_hci_device_regex = re.compile("^hci(\d+)$")
_mac_address_regex = re.compile(r'^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$')
_hci_device_regex = re.compile(r'^hci(\d+)$')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather see this changed to

_hci_device_regex = re.compile("^hci(\\d+)$")

That woudl remove the warning and keep it as a regular string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough, done

@hbldh hbldh self-assigned this Jul 30, 2019
@hbldh hbldh added Backend: BlueZ Issues and PRs relating to the BlueZ backend enhancement New feature or request labels Jul 30, 2019
@hbldh hbldh added this to the v0.5.0 milestone Jul 30, 2019
@dwolfi dwolfi force-pushed the fix/deprecated/unicodeescape branch from fea3d27 to 7740566 Compare July 31, 2019 06:57
hbldh added a commit that referenced this pull request Aug 1, 2019
Merge branch 'workaroundgmbh-fix/deprecated/unicodeescape' into develop
@hbldh hbldh merged commit 7740566 into hbldh:master Aug 2, 2019
hbldh added a commit that referenced this pull request Aug 2, 2019
macOS support added (thanks to @kevincar)
Merged #80: macOS development
Merged #90 which fixed #89: Leaking callbacks in BlueZ
Merged #92 which fixed #91, Prevent leaking of DBus connections on discovery
Merged #96: Regex patterns
Merged #86 which fixed #83 and #82
Recovered old .NET discovery method to try for #95
@arthur-proglove arthur-proglove deleted the fix/deprecated/unicodeescape branch October 26, 2022 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend: BlueZ Issues and PRs relating to the BlueZ backend enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants