-
Notifications
You must be signed in to change notification settings - Fork 304
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
Use raw literals for regex patterns #96
Conversation
There was a problem hiding this 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
bleak/backends/bluezdbus/utils.py
Outdated
@@ -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})$') |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
bleak/backends/bluezdbus/utils.py
Outdated
_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+)$') |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair enough, done
fea3d27
to
7740566
Compare
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
Should fix this Python 3 related warning: