Search code examples
pythonpython-3.xpycharmpython-dataclasses

How to avoid unexpected argument warning using data classes


I have the following simple code.

@dataclass(frozen=True)
class Test:
    a: bool = True
    b: bool = True
    c: bool = True

    @classmethod
    def create_default(cls) -> 'Test':
        return cls(a=False, b=False, c=False)

I don't understand why PyCharm highlight the line: return cls(a=False, b=False, c=False) with unexpected argument

Am I doing smth wrong?


Solution

  • This is a bug in Pycharm that has been already fixed. Update to the latest version (2018.2.4 when this answer was written)