Closed
Description
I'm wonder if I can get pydantic's custom dataclasses to work with mypy, original issue: pydantic/pydantic#280.
The following code passes mpy validation:
from dataclasses import dataclass
# from pydantic.dataclasses import dataclass
@dataclass
class Test:
test_int: int
test_str: str
Test(test_int=42, test_str='foobar')
However, if I change the import to use from pydantic.dataclasses import dataclass
I get
> mypy --follow-imports=skip test.py
test.py:9: error: Unexpected keyword argument "test_int" for "Test"
test.py:9: error: Unexpected keyword argument "test_str" for "Test
Is this because mypy does somethign special when it seems the standard library dataclasses
import, or because of something erroueous in pydantic's dataclass implementation (code here).
Either way, is there anything I can do to fix this in pydantic?
The class returned by pydantic's @dataclass
decorator should be (almost) identical to the standard lib decorator as it uses dataclasses._process_class()
internally.
Metadata
Metadata
Assignees
Labels
No labels