man-group / pytest-plugins

A grab-bag of nifty pytest plugins
MIT License
561 stars 83 forks source link

pytest-profiling: Invalid Escape Sequence Causes SyntaxWarning in Python 3.12 #238

Open PeterParker opened 2 days ago

PeterParker commented 2 days ago

I'm seeing the following warning in Python 3.12, which does not like the \: escape sequence:

/usr/local/sis/.venv/lib/python3.12/site-packages/pytest_profiling.py:20: SyntaxWarning: invalid escape sequence '\:'
  forbidden_chars = set('/?<>\:*|"')
PeterParker commented 2 days ago

I believe changing the quoted line to the following will fix the warning:

forbidden_chars = set('/?<>\\:*|"')

I.e., the backslash needs to be escaped with a backslash.

Or, use a raw string literal:

forbidden_chars = set(r'/?<>\:*|"')