KEMBAR78
KeyError on import with dataclasses with variable length Tuple · Issue #935 · mypyc/mypyc · GitHub
Skip to content

KeyError on import with dataclasses with variable length Tuple #935

@stevenkaras

Description

@stevenkaras

I ran into this while trying out mypyc and managed to put together a minimal reproduction case:

import dataclasses

@dataclasses.dataclass
class A:
    t: tuple[str, ...]

print(A(t=("hello", "world")).t)

runs as expected with CPython, but when imported after compiling with mypyc fails with:

Python 3.9.6 (default, Aug  6 2021, 00:27:57)
[Clang 12.0.5 (clang-1205.0.22.11)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sandbox
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sandbox.py", line 6, in <module>
    t: tuple[str, ...]
KeyError: 'tuple'
>>>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions