-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
Crash Report
Defining a function named __post_init__
anywhere that isn't a class base-level crashes mypy.
Traceback
lmao.py:1: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.6.1
Traceback (most recent call last):
File "mypy/checker.py", line 585, in accept
File "mypy/nodes.py", line 790, in accept
File "mypy/checker.py", line 994, in visit_func_def
File "mypy/checker.py", line 998, in _visit_func_def
File "mypy/checker.py", line 1081, in check_func_item
File "mypy/plugins/dataclasses.py", line 1091, in is_processed_dataclass
AttributeError: attribute 'metadata' of 'TypeInfo' undefined
lmao.py:1: : note: use --pdb to drop into pdb
To Reproduce
Top-level:
def __post_init__(): ...
Nested:
class Foo:
def func(self):
def __post_init__(): ...
The following does not cause mypy to crash:
__post_init__ = lambda _: ...
Nor does
class Foo:
def __post_init__(): ...
Your Environment
- mypy version used: 1.61
- Python version used: Reproduced on 3.9 and 3.11
- Operating system and version: macOS Sonoma 14.1