Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mypy error: Type argument "X" of "DataclassSerializer" must be a subtype of "Dataclass" #64

Closed
intgr opened this issue Nov 7, 2022 · 3 comments

Comments

@intgr
Copy link
Contributor

intgr commented Nov 7, 2022

When using code like:

@dataclass
class MyDataclass:
    blah: int


class MySerializer(DataclassSerializer[MyDataclass]):
    ...

mypy version 0.990 will display a warning like:

Type argument "MyDataclass" of "DataclassSerializer" must be a subtype of "Dataclass"

I am not yet sure whether this is a bug or intentional change, reported to mypy for clarification: python/mypy#14029

@oxan
Copy link
Owner

oxan commented Nov 7, 2022

Marking __dataclass_fields__ as a ClassVar in the protocol makes sense imo. It's unfortunate that older mypy doesn't accept that, though.

@intgr
Copy link
Contributor Author

intgr commented Nov 8, 2022

@oxan Are you fixing this or should I submit a PR?

@oxan
Copy link
Owner

oxan commented Nov 8, 2022

I can commit a fix tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants