Skip to content

Warn on collection membership checks that resolve to Never #5218

Description

Is your feature request related to a problem? Please describe.
Currently, membership checks that resolve to Never don't produce a warning, but this is almost always a mistake. An example is:

a: set[int] = {1, 2, 3}
b: set[str] = {"a", "b", "c"}

for item in a:
    if item in b:
        print(item) # type here is Never

Describe the solution you'd like
This membership check will resolve to Never (always False), it'd be nice if there was an optional configuration to make this a warning diagnostic, similar to reportUnnecessaryComparison.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions