Syntax warnings with Python 3.12
Describe the bug Syntax warnings with Python 3.12.
To Reproduce In a checkout:
python3.12 -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
python -B -c 'import onepassword'
Output:
/Users/kam/src/1password-client/onepassword/utils.py:9: SyntaxWarning: invalid escape sequence '\@'
master_password_regex = 'Enter the password for [a-zA-Z0-9._%+-]+\@[a-zA-Z0-9-]+\.[a-zA-z]{2,4} at ' \
/Users/kam/src/1password-client/onepassword/utils.py:10: SyntaxWarning: invalid escape sequence '\.'
'[a-zA-Z0-9-.]+\.1password+\.[a-zA-z]{2,4}'
/Users/kam/src/1password-client/onepassword/utils.py:70: SyntaxWarning: invalid escape sequence '\('
index = p.expect([pexpect.EOF, "\(401\) Unauthorized"])
Note that -B is required to not write bytecode, because once the code is parsed, the warnings don't come again.
Also, Ruff is useful for checking for this and other code gotchas.
❯ ruff check --select W605 --target-version py312
onepassword/utils.py:9:66: W605 [*] Invalid escape sequence: `\@`
onepassword/utils.py:9:81: W605 [*] Invalid escape sequence: `\.`
onepassword/utils.py:10:40: W605 [*] Invalid escape sequence: `\.`
onepassword/utils.py:10:52: W605 [*] Invalid escape sequence: `\.`
onepassword/utils.py:70:45: W605 [*] Invalid escape sequence: `\(`
onepassword/utils.py:70:50: W605 [*] Invalid escape sequence: `\)`
Found 6 errors.
[*] 6 fixable with the `--fix` option.
Expected behavior No output.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: macOS
Additional context See also:
- https://stackoverflow.com/a/77531416
- https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
Thanks for submitting this issue @datalogics-kam. We should probably be more specific in our README since we only actually test and support Python 3.10 for now, I would be tempted to bump this to 3.11 but waiting for a more stable 3.12 to support that (probably will jump to 3.12 in 2025 so will come back to this issue then)
(Still bumping in to this - I get errors on 3.13 as well)