Do not force django.contrib.* dependencies (#535)

* Do not force django.contrib.* dependencies

Fixes #428.
Fixes #534.

* Add one more test with contenttypes installed, but auth not
This commit is contained in:
Lysandros Nikolaou
2020-11-24 13:38:03 +02:00
committed by GitHub
parent f3e0872d6e
commit d9c851abce
3 changed files with 25 additions and 2 deletions

View File

@@ -8,6 +8,9 @@ from mypy_django_plugin.lib import helpers
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
# Imported here because django isn't properly loaded yet when module is loaded
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import AnonymousUser