Skip to content

Commit

Permalink
fix: correct the bad '\Z' escape sequence in a regex (#79)
Browse files Browse the repository at this point in the history
Problem:

We're seeing errors in a mingw64 environment:
```
SyntaxWarning: invalid escape sequence '\Z'  _standard_string_regex = ...
SyntaxWarning: invalid escape sequence '\Z'  _file_dialog_filter_pattern_regex = ...
```

Solution:

These should be raw strings. '\Z' is a special regex marker signifying
the end of string.

Signed-off-by: Daniel Neilson <[email protected]>
  • Loading branch information
ddneilson authored Feb 21, 2024
1 parent 584b681 commit a1cf4b0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/openjd/model/v2023_09/_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class ValueReferenceConstants(Enum):
# C1 = 0x80-0x9F
# https://www.unicode.org/charts/PDF/U0080.pdf
_Cc_characters = r"\u0000-\u001F\u007F-\u009F"
_standard_string_regex = f"(?-m:^[^{_Cc_characters}]+\Z)"
_standard_string_regex = rf"(?-m:^[^{_Cc_characters}]+\Z)"

# Latin alphanumeric, starting with a letter
_identifier_regex = r"(?-m:^[A-Za-z_][A-Za-z0-9_]*\Z)"
Expand All @@ -131,7 +131,9 @@ class ValueReferenceConstants(Enum):
# c. Wildcard characters "*", "?", "[", "]".
# d. Characters commonly disallowed in paths "#", "%", "&", "{", "}", "<", ">",
# "$", "!", "'", "\"", ":", "@", "`", "|", "=".
_file_dialog_filter_pattern_regex = f"(?-m:^(?:\\*|\\*\\.\\*|\\*\\.[^{_Cc_characters}\\/\\*\\?\\[\\]#%&\\{{\\}}<>\\$\\!\\'\\\":@`\\|=]+)\Z)"
_file_dialog_filter_pattern_regex = (
rf"(?-m:^(?:\*|\*\.\*|\*\.[^{_Cc_characters}\\/\*\?\[\]#%&\{{\}}<>\$\!'\\\":@`|=]+)\Z)"
)


class JobTemplateName(FormatString):
Expand Down

0 comments on commit a1cf4b0

Please sign in to comment.