Skip to content

Commit

Permalink
Fix SyntaxWarning/DeprecationWarning
Browse files Browse the repository at this point in the history
This is a `DeprecationWarning` in Python<3.12 and a `SyntaxWarning` in
Python>=3.12 since `\Z` is an invalid escape sequence. In every case,
this should be made a raw string as also described in the according
[change note]:

    A backslash-character pair that is not a valid escape sequence now
    generates a SyntaxWarning, instead of DeprecationWarning. For example,
    re.compile("\d+\.\d+") now emits a SyntaxWarning ("\d" is an invalid
    escape sequence, use raw strings for regular expression:
    re.compile(r"\d+\.\d+")). In a future Python version, SyntaxError will
    eventually be raised, instead of SyntaxWarning.

[change note]: https://docs.python.org/3.12/whatsnew/3.12.html#other-language-changes
  • Loading branch information
sbrandtb committed Jan 25, 2024
1 parent a9c63b7 commit e4cc9c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion s3path/current_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def _compile_pattern_parts(self, prefix, pattern, bucket):
new_regex_pattern += f'{self._path._flavour.sep}*(?s:{part.replace("**", ".*")})'
continue
new_regex_pattern += f'{self._path._flavour.sep}{fnmatch.translate(part)[:-2]}'
new_regex_pattern += '/*\Z'
new_regex_pattern += r'/*\Z'

return re.compile(new_regex_pattern).fullmatch

Expand Down

0 comments on commit e4cc9c8

Please sign in to comment.