Skip to content

Incompatible types in assignment #173

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
ynikulin opened this issue Sep 19, 2019 · 2 comments
Closed

Incompatible types in assignment #173

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

Comments

@ynikulin
Copy link

ynikulin commented Sep 19, 2019

Bug report

Hello,

With a new version, couple issues were fixed but got new. In general looks like all explainable.

So I got:

apps/users/models.py:95: error: Incompatible types in assignment (expression has type "UserManager[User]", base class "AbstractUser" defined the type as "UserManager[AbstractUser]")
apps/currencies/amounts.py:150: error: Incompatible types in assignment (expression has type "ForeignKey[Union[Currency, Combinable], Currency]", base class "AmountStringRepresentationMixin" defined the type as "Currency")

apps/currencies/amounts.py:171: error: Cannot determine type of 'currency'
apps/currencies/amounts.py:175: error: Cannot determine type of 'currency'
apps/currencies/amounts.py:177: error: Cannot determine type of 'currency'
apps/demo/models.py:348: error: Cannot determine type of 'objects'
apps/auth/tasks.py:30: error: Cannot determine type of 'objects'
core/tests.py:115: error: Cannot determine type of 'objects'
views/accounts/users.py:139: error: Cannot determine type of 'objects'
views/accounts/users.py:160: error: Cannot determine type of 'objects'
views/auth.py:89: error: Cannot determine type of 'objects'
views/auth.py:317: error: Cannot determine type of 'objects'
views/auth.py:388: error: Cannot determine type of 'objects'

Look like the first two issues are main. If look rest of issues it's:

(For first issue)
user = User.objects.get(email=email.lower())
or
User.objects.create
or
User.objects.get_or_create

(for second)
currency=self.currency
or
self.currency == other.currency

Looks like if I got some issue with some stuff - rest manipulation in code makes an error.

A little bit code, for reproducing:

(for first issue)

from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
    ....
    objects = UserManager()  <----- an error
    ...

and

from django.contrib.auth.models import BaseUserManager
class UserManager(BaseUserManager):
    .....

(for second)

class BaseAmount(AmountStringRepresentationMixin[models.DecimalField],
                               AmountComparatorMixin[models.DecimalField],
                               models.Model):
    ...
    currency = models.ForeignKey(Currency,                <----- an error
                                 related_name='+',
                                 verbose_name=_('Currency'),
                                 on_delete=models.PROTECT)
    ...

I will be glad to any advice :)

  • OS: Ubuntu 18.04.3 LTS
  • python version: 3.7
  • django version: 2.2.5
  • mypy version: 0.720
  • django-stubs version: 1.1.0
@ynikulin ynikulin added the bug Something isn't working label Sep 19, 2019
@mkurnikov
Copy link
Member

mkurnikov commented Sep 23, 2019

First issue, I believe, is the same as #174

For the second one, I need a code for AmountStringRepresentationMixin to be able to fix it.

@ynikulin
Copy link
Author

ynikulin commented Oct 8, 2019

Hello,

With 1.2.0, all looks fine. I will an issue. Thanks!

@ynikulin ynikulin closed this as completed Oct 8, 2019
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