typeddjango / django-stubs

PEP-484 stubs for Django
MIT License
1.52k stars 425 forks source link

fix handling of explicit `objects` annotation #2241

Closed asottile closed 2 weeks ago

asottile commented 2 weeks ago

test originally failing with:

_______________________ from_queryset_model_inheritance ________________________
/home/asottile/workspace/django-stubs/tests/typecheck/managers/querysets/test_from_queryset.yml:47: 
E   pytest_mypy_plugins.utils.TypecheckAssertionError: Invalid output: 
E   Actual:
E     myapp/models:10: error: Incompatible types in assignment (expression has type "MyManager[Base]", variable has type "MyManager[Self]")  [assignment] (diff)
E   Expected:
E     (empty)

we use this pattern at sentry to ensure the correct types for model classes which inherit from our base model