Skip to content

Should non-overlapping comparisons allowed in assertions? #8294

Open
@JukkaL

Description

@JukkaL

The following assertion generates an error when using --strict-equality, but perhaps it should be allowed, since an assertion can test something that should be impossible?

from typing import List

def f(x: List[int]) -> None:
    assert 'foo' not in x  # Error, but should this be okay?
    ...

I saw a few examples similar to the above in production code and had to use # type: ignore[...] with them, which didn't feel optimal.

@ilevkivskyi What do you think?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions