【发布时间】:2019-03-20 22:09:26
【问题描述】:
@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"
如果有人能帮助我克服这个问题会很有帮助。谢谢
【问题讨论】:
标签: typechecking python-3.7 mypy python-dataclasses