Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm typehint on subclass using attrs

Pycharm is complaining about an unexpected argument to MyClass instance. Is there a way around this?

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"
like image 414
GlaceCelery Avatar asked Sep 17 '18 02:09

GlaceCelery


1 Answers

This is a bug in PyCharm 2018.2

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

like image 92
Marcel Wilson Avatar answered Nov 15 '22 11:11

Marcel Wilson