ericvsmith / dataclasses

Apache License 2.0
587 stars 53 forks source link

mypy: unexpected keyword-argument #125

Closed dfee closed 6 years ago

dfee commented 6 years ago

Consider the following class:

import dataclasses as dc

@dc.dataclass
class Dimmension:
    kind: str

    @classmethod
    def create(
            cls,
            kind,
        ) -> 'Dimmension':
        return cls(kind=kind)

the last line of the constructor actually throws a mypy error: Unexpected keyword argument "kind" for "Dimmension".

Removing "Dimmension" as the return annotation from create removes the error.

ilevkivskyi commented 6 years ago

This is not a dataclass problem, dataclasses are not yet supported by mypy, the support is planned to be added soon (in time for Python 3.7 release).

ericvsmith commented 6 years ago

Closing, since this isn't a dataclasses 3.6 back port issue.