Skip to content

Disable PLR1714 while it is incompatible with mypy #324

@thierry-martinez

Description

@thierry-martinez

PLR1714 suggests rewriting code like:

if cmd.kind == CommandKind.X or cmd.kind == CommandKind.Z: ...

into

if cmd.kind in {CommandKind.X, CommandKind.Z}: ...

While it can be considered to legitimately improve readability, mypy currently does not understand that cmd is an instance of X or Z in the if-block, whereas mypy is able to understand it in the original code with or.

@EarlMilktea suggests that we disable PLR1714 while it is incompatible with mypy.

A caveat is that we won't benefit from such suggestions in case where we don't need mypy's type narrowing, but I guess most of the time we are in a context where we need such narrowing, so it makes sense to disable the rule entirely.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions