Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[mypyc]dataclass andNamedTuple fail when typed withnp.ndarray #20365

Closed
Labels
bugmypy got something wrong
@lgeiger

Description

@lgeiger

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 frommypy.ini (and other config files): none
  • Python version used: 3.12.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp