Open
Description
Bug Report
When using any container (set, frozenset, list, tuples...) containing Literal
based types, the --strict-equality
is not detecting any issues when I use the membership operator in a non-overlapping check.
To Reproduce
from typing import Literal
OPTIONS = Literal["a", "b"]
var: list[OPTIONS] = ["a"]
if "c" in var: # MYPY OK
pass
Expected Behavior
When the flag --strict-equality is set, I would expect that mypy
raises an erorr here. Same as it does when I do a non-overlapping equality check:
from typing import Literal
OPTIONS = Literal["a", "b"]
var: list[OPTIONS] = ["a"]
if var[0] == "c": # error: Non-overlapping equality check (left operand type: "Literal['a', 'b']", right operand type: "Literal['c']") [comparison-overlap]
pass
Actual Behavior
No errors are raised
Your Environment
Using Mypy
version 1.9.0
Metadata
Metadata
Assignees
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
[-]Strict equality flag not working with container filled with `Literal` types[/-][+]`--strict-equality` flag not working with membership operator and `Literal` types[/+]