Skip to content

Commit

Permalink
Cache dynamically created manager nodes (#840)
Browse files Browse the repository at this point in the history
- Non plugin generated, "cross_ref"s points to dynamically
  created managers (e.g. `Model.objects`) and can make Mypy fail on
  cached runs
  • Loading branch information
flaeppe authored Mar 31, 2022
1 parent 4e3f9d6 commit 92e5f20
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions mypy_django_plugin/transformers/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ def create_new_manager_class_from_from_queryset_method(ctx: DynamicClassDefConte
new_manager_info,
name=name,
sym_type=AnyType(TypeOfAny.special_form),
no_serialize=True,
)

# we need to copy all methods in MRO before django.db.models.query.QuerySet
Expand Down Expand Up @@ -278,9 +277,7 @@ def create_new_manager_class_from_from_queryset_method(ctx: DynamicClassDefConte
)

# Insert the new manager (dynamic) class
assert semanal_api.add_symbol_table_node(
ctx.name, SymbolTableNode(GDEF, new_manager_info, plugin_generated=True, no_serialize=True)
)
assert semanal_api.add_symbol_table_node(ctx.name, SymbolTableNode(GDEF, new_manager_info, plugin_generated=True))


def fail_if_manager_type_created_in_model_body(ctx: MethodContext) -> MypyType:
Expand Down

0 comments on commit 92e5f20

Please sign in to comment.