Skip to content

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

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

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.

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