Skip to content

Incompatible type with generic dataclasses inheritance #7715

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

Closed
Eugene-1984 opened this issue Oct 15, 2019 · 1 comment
Closed

Incompatible type with generic dataclasses inheritance #7715

Eugene-1984 opened this issue Oct 15, 2019 · 1 comment

Comments

@Eugene-1984
Copy link

The following MWE:

from typing import Generic, TypeVar
import dataclasses

T = TypeVar('T')

@dataclasses.dataclass()
class A(Generic[T]):
    attr: T

A(attr=0)  # OK!

@dataclasses.dataclass()
class B(A[float]):
    ...

B(attr=float(0))
# Argument "attr" to "B" has incompatible type "float"; expected "T"

fails with "Argument "attr" to "B" has incompatible type "float"; expected "T"" error in mypy. But the B class specifies T to be float, how to fix that error?

@ilevkivskyi
Copy link
Member

This is a duplicate of #7520

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

No branches or pull requests

2 participants