Skip to content

FAST002 fix is invalid with ... #20800

@CoderJoshDK

Description

@CoderJoshDK

Summary

FAST002 converts parameters into their Annotated counterparts. If the source code contains an ellipses type (literal ...) then the fix will generate incorrect semantics.

Take the following signature:

@router.get("/available")
async def get_available(
    ghl_account_id: str = Query(..., description="GHL account identifier"),
) -> SystemsAvailableResponse: ...

The use of ... in the default for Query is valid syntax (should be picked up in a lint that you shouldn't do this, but it is "valid").
When trying to run fix, you get:

@router.get("/available")
async def get_available(
    ghl_account_id: Annotated[str, Query(description="GHL account identifier")] = ...,
) -> SystemsAvailableResponse: ...

When in reality, there is no default value and ruff should convert it to:

@router.get("/available")
async def get_available(
    ghl_account_id: Annotated[str, Query(description="GHL account identifier")],
) -> SystemsAvailableResponse: ...

Version

ruff 0.14.0

Metadata

Metadata

Assignees

No one assigned

    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