Skip to content

fix: parenthesize multiple exceptions in deps.py to fix SyntaxError on Python <= 3.13 - #2484

Closed
H-XX-D wants to merge 2 commits into
fastapi:masterfrom
H-XX-D:fix-deps-exception-tuple
Closed

H-XX-D wants to merge 2 commits into
fastapi:masterfrom
H-XX-D:fix-deps-exception-tuple

Conversation

@H-XX-D

@H-XX-D H-XX-D commented Sep 19, 2026

Copy link
Copy Markdown

Problem

In backend/app/api/deps.py, line 36 catches multiple exceptions without enclosing parentheses:

except InvalidTokenError, ValidationError:

On Python 3 (including Python 3.10, 3.11, 3.12, and 3.13), running python3 -m py_compile backend/app/api/deps.py fails at parse time:

  File "backend/app/api/deps.py", line 36
    except InvalidTokenError, ValidationError:
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized

Solution

Parenthesize the exception types to except (InvalidTokenError, ValidationError):.

Verification

Verified with python3 -m py_compile backend/app/api/deps.py (exits 0).

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@H-XX-D

H-XX-D commented Sep 20, 2026

Copy link
Copy Markdown
Author

Closing after checking the repository's supported runtime. backend/pyproject.toml already requires >=3.14,<4.0 and sets Ruff's target to py314.

The original except InvalidTokenError, ValidationError: syntax is valid in Python 3.14 under PEP 758, and I confirmed that the unchanged file compiles with CPython 3.14.6. The reported failure occurs on Python 3.13, outside the supported range.

The formatting commit restored the original syntax, so this PR also has no remaining diff. This was a false positive for the project's supported runtime. Sorry for the noise.

@H-XX-D H-XX-D closed this Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants