Skip to content

FBT001 preview behavior may lead to false positives #14444

@dylwil3

Description

@dylwil3

The rule boolean-type-hint-positional-argument (FBT001) was extended in #7501 , under preview, to also flag positional arguments that have a type hint with any union of types that includes bool.

The intent of the rules is specifically to find places where a boolean is used as a (binary) flag, in a positional argument. If an argument has a type hint of bool or even bool | None, it makes sense to predict that the argument is being used as a flag. But the preview behavior allows any union, even, say bool | str | MyClass. This seems like a situation where it's a bit of a stretch to assume that the user is using the boolean as a flag.

Maybe the concern is unfounded and this doesn't actually happen in the real world, but I figured the community could weigh in a bit on the point before stabilizing this preview behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    previewRelated to preview mode featuresruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions