Should non-overlapping comparisons allowed in assertions?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no file or test; first reproduce the example with --strict-equality and trace the assertion check that reports the comparison error. Decide whether an impossible membership assertion should be accepted, then define the expected diagnostic behavior and coverage for the shown List[int] case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100