使用attrs在子类上的Pycharm typehint

时间:2018-09-17 02:16:12

标签: pycharm python-attrs

Pycharm抱怨MyClass实例的意外参数。有办法解决吗?

import attr

@attr.s
class _Super:
    """ My Super class"""
    x: str = attr.ib(validator=attr.validators.instance_of(str))

@attr.s
class MyClass(_Super):
    """ My Sub class"""
    y:str = attr.ib(validator=attr.validators.instance_of(str))

x = MyClass(x="a", y="b")  # (x variable) Pycharm Typehint: "Unexpected argument"

1 个答案:

答案 0 :(得分:2)

这是PyCharm 2018.2中的错误

https://youtrack.jetbrains.com/issue/PY-28506