ruff/crates/ruff_linter/resources/test/fixtures/fastapi
Hengky Kurniawan a802d7a0ea
[`fastapi`] Handle ellipsis defaults in FAST002 autofix (`FAST002`) (#20810)
## Summary

Implement handling of ellipsis (`...`) defaults in the `FAST002` autofix
to correctly differentiate between required and optional parameters in
FastAPI route definitions.

Previously, the autofix did not properly handle cases where parameters
used `...` as a default value (to indicate required parameters). This
could lead to incorrect transformations when applying the autofix.

This change updates the `FAST002` autofix logic to:
- Correctly recognize `...` as a valid FastAPI required default.
- Preserve the semantics of required parameters while still applying
other autofix improvements.
- Avoid incorrectly substituting or removing ellipsis defaults.

Fixes https://github.com/astral-sh/ruff/issues/20800

## Test Plan

Added a new test fixture at:
```crates/ruff_linter/resources/test/fixtures/fastapi/FAST002_2.py```
2025-10-21 02:47:13 +00:00
..
FAST001.py Use TypeChecker for detecting fastapi routes (#15093) 2024-12-21 15:45:28 +01:00
FAST002_0.py [`FastAPI`] Update `Annotated` fixes (`FAST002`) (#15462) 2025-01-15 13:05:53 -05:00
FAST002_1.py [`FastAPI`] Update `Annotated` fixes (`FAST002`) (#15462) 2025-01-15 13:05:53 -05:00
FAST002_2.py [`fastapi`] Handle ellipsis defaults in FAST002 autofix (`FAST002`) (#20810) 2025-10-21 02:47:13 +00:00
FAST003.py [`ruff`] Skip autofix for keyword and `__debug__` path params (#20960) 2025-10-20 16:37:20 -07:00