mypyc icon indicating copy to clipboard operation
mypyc copied to clipboard

mypyc generates AttributeError: exception on basic use of InitVar

Open bertbarabas opened this issue 3 years ago • 0 comments

mypy version: 0.960 python version: 3.10.4 Running on Windows 11

just import the following code into a CPython REPL:

from dataclasses import InitVar, dataclass


@dataclass
class TestInitVar:
    some_initvar: InitVar = None

    def __post_init__(
        self,
        some_initvar,
    ):
        pass

causes:

(.venv) PS C:\Projects\CaptureFile-MyPyC> python
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import Test_01
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "Test_01.py", line 5, in <module>
    class TestInitVar:
AttributeError: some_initvar
>>>

bertbarabas avatar May 29 '22 00:05 bertbarabas