Skip to content

RUF029 gives false positives with FastApi routes #12925

@TomerBin

Description

@TomerBin

I would like to suggest that RUF029 will skip functions that are FastApi routes. In their docs, it is explicitly mentioned that sometimes routes should be declared as async function, even when not doing any asynchronous operation.
As a first step we can introduce a new rule setting that will allow opting into this new behavior.

One caveat is with FastApi dependencies that we should handle the same way but we can't since dependencies are just native functions and can't be detected in their deceleration (only in usage), but I believe that ignoring routes and keeping the current behavior for dependencies is a good step.

If you find this reasonable, I would like to implement it 😊

Metadata

Metadata

Assignees

No one assigned

    Labels

    previewRelated to preview mode featuresruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions