Expand override manager create test + move to assert_type - #3559
Merged
UnknownPlatypus merged 2 commits intoAug 4, 2026
Merged
UnknownPlatypus merged 2 commits into
UnknownPlatypus merged 2 commits into
Conversation
1 task done
crgwbr
added a commit
to thelabnyc/django-oscar-stubs
that referenced
this pull request
Sep 14, 2026
django-stubs 6.1.1 dropped `objects: ClassVar[Manager[Self]]` from `Model` in favour of a metaclass `__getattr__` fallback (typeddjango/django-stubs#3559). Type checkers still resolve `Model.objects` through it, but stubtest only compares declared attributes, so all 63 models that rely on the inherited default started reporting `objects is not present in stub`. Allowlist the attribute rather than declaring it per model: an explicit `ClassVar[Manager[X]]` in the stubs would shadow the manager type django-stubs' plugin synthesizes, which would cost downstream users their custom manager methods. The allowlist matches by name only, so stubtest no longer verifies any `objects` attribute, the explicit custom-manager declarations included; manager types stay guarded by the django-stubs plugin and the mypy-plugins suite. The regex replaces eight exact per-model entries it subsumes. This was failing on master too, since tox resolves `django-stubs>=6.1`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have made things!
Expand the coverage for maanger create overloads.
The unparametrized case exercise a bit of plugin but not the others two so I moved it to assert_type.
This also revealed that our typing of
Model.objectsasClassVar[Manager[Self]]is already a bit problematic with pyright and pyrefly (see the type-ignore's). Given this exemple:I get these revealed types
To me our declaration in the stubs should not impact regular class level assignment inference and I would expect
objectsto have the same type asfoo. The plugin should only apply the "does not exist on abstract model" bit, the rest should be regular inference.I'm exploring how to improve that, maybe with a descriptor in a followup pr
Related issues
Still trying to cut the bulk for #2776
AI Policy