-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed as not planned
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
Mypy doesn't raise an error when checking if an element is in an Iterable
while it does when directly using __contains__
.
To Reproduce
from typing import Any, Iterable
def iterable_contains(iterable: Iterable[Any], element: Any):
if element in iterable: # No error but I thingk it should raise
print(element)
if iterable.__contains__(element): # Error, expected
print(element)
Expected Behavior
Mypy should raise an error on the first if statement
Actual Behavior
But it doesn't
Your Environment
Found this with earlier python and mypy versions but example is reproducible with :
- Mypy version used: 1.7.0
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini
(and other config files): None - Python version used: 3.11.0
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong