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

Failing mypy tests in users app with django-stubs #2395

Closed
danifus opened this issue Jan 11, 2020 · 1 comment · Fixed by #2396
Closed

Failing mypy tests in users app with django-stubs #2395

danifus opened this issue Jan 11, 2020 · 1 comment · Fixed by #2396
Labels

Comments

@danifus
Copy link
Contributor

danifus commented Jan 11, 2020

What happened?

After installing django-stubs (pip install django-stubs) the typing tests in the users app fail with Name 'settings.AUTH_USER_MODEL' is not defined.

reveal_type(settings.AUTH_USER_MODEL) returns Any which doesn't provide much value. Did this work differently at some stage in the past? If not, an easy fix would be to remove the annotations in the test function signatures.

Furthermore, the type of settings.AUTH_USER_MODEL is str and the user type should be a subclass of a django model. If that is correct, that might be another reason to remove the annotation.

What should've happened instead?

No mypy errors

Steps to reproduce

pip install django-stubs
mypy <project dir>
@browniebroke
Copy link
Member

I don't think it worked differently in the past. We should fix this. PR welcome.

danifus added a commit to danifus/cookiecutter-django that referenced this issue Jan 12, 2020
)

Adds django-stubs as a requirement for local virtualenv. This is
required now that the User Model type is being resolved properly.
danifus added a commit to danifus/cookiecutter-django that referenced this issue Jan 12, 2020
)

Adds django-stubs as a requirement for local virtualenv. This is
required now that the User Model type is being resolved properly.
browniebroke added a commit that referenced this issue Jan 13, 2020
Fix failing mypy tests in users app with django-stubs (#2395)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants