Skip to content

FAST003 syntax error when a path parameter is a Python keyword #20941

@dscorbett

Description

@dscorbett

Summary

The fix for fast-api-unused-path-parameter (FAST003) introduces a syntax error when the path parameter is a Python keyword or __debug__. The diagnostic is still correct but it can’t be fixed automatically. Example:

$ cat >fast003.py <<'# EOF'
from fastapi import FastAPI
app = FastAPI()
@app.get("/imports/{import}")
async def get_import(): ...
# EOF

$ ruff --isolated check fast003.py --select FAST003 --unsafe-fixes --output-format concise -q
fast003.py:3:20: FAST003 [*] Parameter `import` appears in route path, but not in `get_import` signature

$ ruff --isolated check fast003.py --select FAST003 --unsafe-fixes --diff 2>&1 | grep error:
error: Fix introduced a syntax error. Reverting all changes.

Version

ruff 0.14.1 (2bffef5 2025-10-16)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixesRelated to suggested fixes for violations

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions