Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
Closed
Description
Bug Report
Starting with mypyc 1.16.0 typingdataclass orNamedTuple withnp.ndarray fails with aKeyError when mypyc compiled. This worked correctly with mypyc 1.15.0 but started failing with 1.16.0 and is still an issue with1.20.0+dev.4eb6b509d2bdecad2bb638050e052174d1f6b3f8. I haven't checked whether this is only reproducible with np.ndarray. But given that it worked with older versions of mypyc, I expect this mmight be a mypyc issue.
To Reproduce
fromdataclassesimportdataclassimportnumpy@dataclassclassFoo:arr:numpy.ndarrayprint(Foo(np.zeros((1,1,3),dtype=np.uint8)))
or
fromtypingimportNamedTupleimportnumpyasnpclassFoo(NamedTuple):arr:np.ndarrayprint(Foo(np.zeros((1,1,3),dtype=np.uint8)))
compiled with
mypyc test.pypython -c "import test"Expected Behavior
Foo(arr=array([[[0, 0, 0]]], dtype=uint8))Actual Behavior
Traceback (most recent call last): File "<string>", line 1, in <module> File "test.py", line 5, in <module> arr: np.ndarrayKeyError: 'ndarray'Your Environment
- Mypy version used: mypy-1.20.0+dev.4eb6b509d2bdecad2bb638050e052174d1f6b3f8
- Mypy command-line flags: mypyc test.py
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.12.12