Skip to content

Commit 5400a27

Browse files
committed
[chores] Fixed minor regex warnings
1 parent 7608e78 commit 5400a27

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

openwisp_controller/config/base/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def _should_use_dsa(self):
423423

424424
# Check if the device is using stock OpenWrt.
425425
openwrt_match = re.search(
426-
'[oO][pP][eE][nN][wW][rR][tT]\s*([\d.]+)', self.device.os
426+
r'[oO][pP][eE][nN][wW][rR][tT]\s*([\d.]+)', self.device.os
427427
)
428428
if openwrt_match:
429429
if version.parse(openwrt_match.group(1)) >= version.parse('21'):

openwisp_controller/config/validators.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from django.utils.translation import gettext_lazy as _
33

44
key_validator = RegexValidator(
5-
_lazy_re_compile('^[^\s/\.]+$'),
5+
_lazy_re_compile(r'^[^\s/\.]+$'),
66
message=_('Key must not contain spaces, dots or slashes.'),
77
code='invalid',
88
)
@@ -16,9 +16,9 @@
1616

1717
# device name must either be a hostname or a valid mac address
1818
hostname_regex = (
19-
'^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}'
20-
'[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9]'
21-
'[a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$'
19+
r'^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}'
20+
r'[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9]'
21+
r'[a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$'
2222
)
2323
device_name_validator = RegexValidator(
2424
_lazy_re_compile('{0}|{1}'.format(hostname_regex, mac_address_regex)),

openwisp_controller/connection/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
'type': 'string',
6666
'minLength': 6,
6767
'maxLength': 30,
68-
'pattern': '[\S]',
68+
'pattern': r'[\S]',
6969
}
7070
},
7171
},

0 commit comments

Comments
 (0)