Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax warnings with Python 3.12 #67

Open
datalogics-kam opened this issue Oct 15, 2024 · 1 comment
Open

Syntax warnings with Python 3.12 #67

datalogics-kam opened this issue Oct 15, 2024 · 1 comment

Comments

@datalogics-kam
Copy link

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:

@dtpryce
Copy link
Collaborator

dtpryce commented Oct 16, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants