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

traceback when not using django.contrib.auth #318

Closed
sbdchd opened this issue Feb 6, 2020 · 1 comment
Closed

traceback when not using django.contrib.auth #318

sbdchd opened this issue Feb 6, 2020 · 1 comment
Labels
bug Something isn't working crash "Internal error" crashes from mypy mypy-plugin Issues specific to mypy_django_plugin

Comments

@sbdchd
Copy link

sbdchd commented Feb 6, 2020

Bug report

What's wrong

The django-stubs mypy plugin fails when not using django's django.contrib.auth

poetry install

# if we run mypy we get a traceback

❯ poetry run mypy --show-traceback --config-file mypy.ini .
./core/views.py:6: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.761
Traceback (most recent call last):
  File "mypy/checker.py", line 399, in accept
  File "mypy/nodes.py", line 1062, in accept
  File "mypy/checker.py", line 2004, in visit_assignment_stmt
  File "mypy/checker.py", line 2046, in check_assignment
  File "mypy/checker.py", line 2746, in check_lvalue
  File "mypy/checkexpr.py", line 1932, in analyze_ordinary_member_access
  File "mypy/checkmember.py", line 126, in analyze_member_access
  File "mypy/checkmember.py", line 143, in _analyze_member_access
  File "mypy/checkmember.py", line 225, in analyze_instance_member_access
  File "mypy/checkmember.py", line 376, in analyze_member_var_access
  File "mypy/checkmember.py", line 593, in analyze_var
  File "/Users/steve/Downloads/django-attempt/.venv/lib/python3.7/site-packages/mypy_django_plugin/transformers/request.py", line 11, in set_auth_user_model_as_type_for_request_user
    model_cls = django_context.apps_registry.get_model(auth_user_model)
  File "/Users/steve/Downloads/django-attempt/.venv/lib/python3.7/site-packages/django/apps/registry.py", line 205, in get_model
    app_config = self.get_app_config(app_label)
  File "/Users/steve/Downloads/django-attempt/.venv/lib/python3.7/site-packages/django/apps/registry.py", line 162, in get_app_config
    raise LookupError(message)
LookupError: No installed app with label 'auth'.
./core/views.py:6: : note: use --pdb to drop into pdb

minimal repo: https://github.com/sbdchd/django-stubs-bug-repo

How is that should be

Ideally django-stubs would work when not having the django.contrib.auth app in INSTALLED_APPS

System information

  • OS: Mac OS 10.15
  • python version: 3.7.6
  • django version: 2.2
  • mypy version: 0.761.0
  • django-stubs version: 1.4
@sbdchd sbdchd added the bug Something isn't working label Feb 6, 2020
@intgr intgr added mypy-plugin Issues specific to mypy_django_plugin crash "Internal error" crashes from mypy labels Nov 8, 2022
@flaeppe
Copy link
Member

flaeppe commented Jan 24, 2023

I think this should be closed via #535. As it added these lines:

def set_auth_user_model_as_type_for_request_user(ctx: AttributeContext, django_context: DjangoContext) -> MypyType:
if not django_context.apps_registry.is_installed("django.contrib.auth"):
return ctx.default_attr_type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash "Internal error" crashes from mypy mypy-plugin Issues specific to mypy_django_plugin
Development

No branches or pull requests

3 participants