liormizr / s3path

s3path is a pathlib extension for AWS S3 Service
Apache License 2.0
208 stars 39 forks source link

Fix SyntaxWarning/DeprecationWarning #158

Closed sbrandtb closed 8 months ago

sbrandtb commented 8 months ago

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.
 ❯ docker run --rm -it python:3.11-slim python -c "a = ''; a += '/*\Z'; print(a)"
/*\Z

 ❯ docker run --rm -it python:3.11-slim python -c "a = ''; a += r'/*\Z'; print(a)"
/*\Z

 ❯ docker run --rm -it python:3.12-slim python -c "a = ''; a += '/*\Z'; print(a)"
<string>:1: SyntaxWarning: invalid escape sequence '\Z'

/*\Z

 ❯ docker run --rm -it python:3.12-slim python -c "a = ''; a += r'/*\Z'; print(a)"
/*\Z
liormizr commented 8 months ago

Nice one Thanks for the fix @sbrandtb

sbrandtb commented 8 months ago

@liormizr could we maybe have a patch release? :slightly_smiling_face:

Our pipelines fail on warnings and we are possibly not the only ones having them set up like that

liormizr commented 8 months ago

@sbrandtb sure Version 0.5.2 deployed