blackducksoftware / hub-rest-api-python

HUB REST API Python bindings
Apache License 2.0
89 stars 104 forks source link

Fix SyntaxWarning: invalid escape sequence #255

Open jfcherng opened 9 months ago

jfcherng commented 9 months ago

As the title., for Python 3.12.

jfcherng commented 5 months ago

If you need more information for reproduction,

test.py

from blackduck.Utils import get_resource_name

get_resource_name({'_meta': { 'href': 'https://a.b' }})

and then

$ python -Walways test.py  # where python is python 3.12

You will get

/home/jfcherng/repos/sdlc/hub-rest-api-python/.venv/lib/python3.12/site-packages/blackduck/Utils.py:104: SyntaxWarning: invalid escape sequence '\w'
  if re.search("^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$", part):
/home/jfcherng/repos/sdlc/hub-rest-api-python/.venv/lib/python3.12/site-packages/blackduck/Utils.py:35: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  def iso8601_timespan(days_ago, from_date=datetime.utcnow(), delta=timedelta(weeks=1)):
parts = https://a.b