diff --git a/mypy_django_plugin/main.py b/mypy_django_plugin/main.py index 254f642..3bc13c4 100644 --- a/mypy_django_plugin/main.py +++ b/mypy_django_plugin/main.py @@ -205,7 +205,7 @@ class NewSemanalDjangoPlugin(Plugin): django_context=self.django_context) info = self._get_typeinfo_or_none(class_name) - if info and info.has_base(fullnames.HTTPREQUEST_CLASS_FULLNAME): + if info and info.has_base(fullnames.HTTPREQUEST_CLASS_FULLNAME) and attr_name == 'user': return partial(request.set_auth_user_model_as_type_for_request_user, django_context=self.django_context) diff --git a/test-data/typecheck/test_request.yml b/test-data/typecheck/test_request.yml index e05260a..aac2a2f 100644 --- a/test-data/typecheck/test_request.yml +++ b/test-data/typecheck/test_request.yml @@ -3,6 +3,8 @@ main: | from django.http.request import HttpRequest reveal_type(HttpRequest().user) # N: Revealed type is 'myapp.models.MyUser' + # check that other fields work ok + reveal_type(HttpRequest().method) # N: Revealed type is 'Union[builtins.str, None]' installed_apps: - myapp additional_settings: