Closed salty-horse closed 9 months ago
The following regular expressions produce syntax warnings with Python 3.12:
piplapis/data/fields.py:398: SyntaxWarning: invalid escape sequence '\-' re_email = re.compile("^[a-zA-Z0-9'._%\-+]+@[a-zA-Z0-9._%\-]+\.[a-zA-Z]{2,24}$") piplapis/data/fields.py:576: SyntaxWarning: invalid escape sequence '\d' tokens = ",".join([re.sub("&dsid=\d+", "", x.thumbnail_token) for x in images_with_tokens]) piplapis/data/utils.py:109: SyntaxWarning: invalid escape sequence '\:' VALID_URL_REGEX = re.compile('^(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:\/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|\/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?$')
Since these are not valid string escape sequences, the \ should be escaped with another \, or the whole string should be marked raw with r''. This used to be a DeprecationWarning, and has now been upgraded to a SyntaxWarning.
\
r''
DeprecationWarning
SyntaxWarning
Thank you @salty-horse for pointing this issue.
Version 5.3.1 have been uploaded to pypi with support for python 3.12
The following regular expressions produce syntax warnings with Python 3.12:
Since these are not valid string escape sequences, the
\
should be escaped with another\
, or the whole string should be marked raw withr''
. This used to be aDeprecationWarning
, and has now been upgraded to aSyntaxWarning
.