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

Incompatible types in assignment with User subclass #174

Open
zacchiro opened this issue Sep 19, 2019 · 3 comments
Open

Incompatible types in assignment with User subclass #174

zacchiro opened this issue Sep 19, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@zacchiro
Copy link

Heya, I've this class deriving from the (concrete) User class:

from django.contrib.auth.models import User, UserManager

class DepositClient(User):
    objects = UserManager()

mypy with django-stubs 1.1.0 is complaining on the objects line that:

error: Incompatible types in assignment
(expression has type "UserManager[DepositClient]",
base class "User" defined the type as "UserManager[User]")

even if DepositClient is a subclass of User and the type variable in Manager is declared as covariant by django-stubs.

This should work out-of-the-box with django-stubs, right?
Or am I missing something here?

@zacchiro zacchiro added the bug Something isn't working label Sep 19, 2019
@mkurnikov
Copy link
Member

This is a case specified in the https://github.com/typeddjango/django-stubs/blob/master/test-data/typecheck/managers/test_managers.yml#L281
It's a mypy limitation, smth around Liskov incompatibility.

@zacchiro
Copy link
Author

zacchiro commented Sep 23, 2019 via email

@mkurnikov
Copy link
Member

Yes, # type: ignore + manual annotation I believe would work (can't test right now).
Until python/mypy#7468 is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants