-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-match-statementPython 3.10's match statementPython 3.10's match statement
Description
Bug Report
Mypy does not identify an AttributeError in match case statement
To Reproduce
fn_attr_defined.py
"""Test attr-defined false negative Mypy."""
import itertools
def check(obj: object) -> None:
match obj:
case itertools.chain():
print("Chain")
case itertools.DoesNotExist():
print("Here there must be a attr-defined mypy error")
case _:
print("Default")
if __name__ == "__main__":
check(1)python3 fn_attr_defined.pyTraceback (most recent call last):
File "fn_attr_defined.py", line 17, in <module>
check(1)
~~~~~^^^
File "fn_attr_defined.py", line 10, in check
case itertools.DoesNotExist():
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'itertools' has no attribute 'DoesNotExist'Expected Behavior
Mypy should return a attr-defined error at line case itertools.DoesNotExist():
Actual Behavior
No errors returned by Mypy
Your Environment
-
Mypy version used:
mypy 1.18.2 (compiled: yes) -
Mypy command-line flags:
mypy --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-codes --no-pretty --config-file=mypy.ini --show-error-end fn_attr_defined.py -
Mypy configuration options from
mypy.ini(and other config files):[mypy] show_column_numbers = True check_untyped_defs = True
-
Python version used:
Python 3.13.7
sterliakov and hauntsaninja
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-match-statementPython 3.10's match statementPython 3.10's match statement