You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "mypy/checkexpr.py", line 4813, in accept
File "mypy/checkexpr.py", line 425, in visit_call_expr
File "mypy/checkexpr.py", line 545, in visit_call_expr_inner
File "mypy/checkexpr.py", line 1197, in check_call_expr_with_callee_type
File "mypy/checkexpr.py", line 1280, in check_call
File "mypy/checkexpr.py", line 1490, in check_callable_call
File "mypy/checkexpr.py", line 1020, in apply_function_plugin
File "/.../python3.10/site-packages/mypy_django_plugin/transformers/settings.py", line 13, in get_user_model_hook
model_cls = django_context.apps_registry.get_model(auth_user_model)
File "/.../python3.10/site-packages/django/apps/registry.py", line 206, in get_model
app_config = self.get_app_config(app_label)
File "/.../python3.10/site-packages/django/apps/registry.py", line 163, in get_app_config
raise LookupError(message)
LookupError: No installed app with label 'auth'.
/.../python3.10/site-packages/pytest_django/fixtures.py:397: : note: use --pdb to drop into pdb
How it should work
get_user_model_hook should not raise an error when there is no auth app.
System information
OS: Ubuntu 22.04.2 LTS
python version: 3.10.6
django version: 3.1
mypy version: 1.0.1
django-stubs version: 1.15.0
django-stubs-ext version: 0.7.0
The text was updated successfully, but these errors were encountered:
I had this exact problem. The Mypy code that throws this uses your settings.AUTH_USER_MODEL. My problem was that I pointed to empty (the __init__.py 😅) settings so the default value of auth.User was used instead of what I put in there.
Bug report
What's wrong
Djangn-stubs causes mypy to crashe with
LookupError
when:django.contrib.auth
is not inINSTALLED_APPS
,get_user_model()
.This happened to me because I'm importing
SettingsWrapper
frompytest_django.fixtures
. Mypy then wants a type forget_user_model
becausepytest_django
'sdjango_user_model
fixture imports and returnsget_user_model()
in that module.When
get_user_model_hook
is called, but theauth
app isn't installed, Django raises aLookupError
. I must admit, I have no idea what it should return.This is similar to #318.
Traceback:
How it should work
get_user_model_hook
should not raise an error when there is noauth
app.System information
python
version:3.10.6
django
version:3.1
mypy
version:1.0.1
django-stubs
version:1.15.0
django-stubs-ext
version:0.7.0
The text was updated successfully, but these errors were encountered: