Skip to content

Commit

Permalink
Fix suggested changes from #820
Browse files Browse the repository at this point in the history
  • Loading branch information
flaeppe committed Jan 16, 2022
1 parent 99f2838 commit 1f0975c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 4 additions & 2 deletions mypy_django_plugin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,13 @@ def get_attribute_hook(self, fullname: str) -> Optional[Callable[[AttributeConte
return partial(request.set_auth_user_model_as_type_for_request_user, django_context=self.django_context)
if info and info.has_base(fullnames.ABSTRACT_USER_MODEL_FULLNAME) and attr_name in ("is_staff", "is_active"):
return partial(set_auth_user_model_boolean_fields, django_context=self.django_context)
if (

is_dynamic_manager_class = (
info
and info.has_base(fullnames.BASE_MANAGER_CLASS_FULLNAME)
and class_name in self._get_current_manager_bases()
):
)
if is_dynamic_manager_class:
return partial(resolve_manager_method, django_context=self.django_context)

return None
Expand Down
4 changes: 1 addition & 3 deletions mypy_django_plugin/transformers/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,7 @@ def create_new_manager_class_from_from_queryset_method(ctx: DynamicClassDefConte
new_manager_info.metaclass_type = new_manager_info.calculate_metaclass_type()
# Stash the queryset fullname which was passed to .from_queryset
# So that our 'resolve_manager_method' attribute hook can fetch the method from that QuerySet class
new_manager_info.metadata.setdefault("django", {})
new_manager_info.metadata["django"].setdefault("from_queryset_manager", {})
new_manager_info.metadata["django"]["from_queryset_manager"] = derived_queryset_fullname
new_manager_info.metadata["django"] = {"from_queryset_manager": derived_queryset_fullname}

if len(ctx.call.args) > 1:
expr = ctx.call.args[1]
Expand Down

0 comments on commit 1f0975c

Please sign in to comment.