@dataclass
class A:
one: int = 0
two: str = ""
@nested_dataclass
class B:
three: A
four: str
@nested_dataclass
class C:
five: B
six: str
obj = C(five={"three":{"one": 23, "two":"narf"}, "four": "zort"}, six="fnord")
print(obj.five.three.two)
根据我猜的功能,这段代码是正确的。但是,当我运行时mypy src --ignore-missing-imports
,我收到以下错误:
run.py:50: error: Unexpected keyword argument "five" for "C"
run.py:50: error: Unexpected keyword argument "six" for "C"
如果有人能帮助我克服这个问题,那将会很有帮助。谢谢