KEMBAR78
Dataclasses with float values error · Issue #926 · mypyc/mypyc · GitHub
Skip to content

Dataclasses with float values error #926

@f4hy

Description

@f4hy

Surprized to find that dataclasses which contain floats do not work

"""compiletest.py"""
from dataclasses import dataclass

@dataclass
class TestClass:
    x: float
    y: float
    name: str

def run():
    foo = TestClass(x=1.0, y=2.2, name="fred")
    print(foo)

simply running mypyc compiletest.py and using it with

"""main.py"""
import compiletest

if __name__ == "__main__":
    compiletest.run()

erros with

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    import compiletest
  File "compiletest.py", line 5, in <module>
    x: float
KeyError: 'float'

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