Type template attrs on SingletonModelAdmin - #159
Open
vokracko wants to merge 1 commit into
Open
Conversation
`object_history_template` and `change_form_template` are the only unannotated attrs on `SingletonModelAdmin`. Unannotated, mypy infers them as bare `str` - but `ModelAdmin` types them `ClassVar[_TemplateForResponseT | None]` via django-stubs. Subclass `SingletonModelAdmin` next to another `ModelAdmin` subclass that keeps the stub type and the two bases disagree: ``` error: Definition of "object_history_template" in base class "SingletonModelAdmin" is incompatible with definition in base class "Foo" [misc] ``` Annotating both to match the base clears it. Runtime unaffected, `from __future__ import annotations` is already on.
vokracko
force-pushed
the
type-singleton-admin-templates
branch
from
July 20, 2026 15:01
31f42aa to
ba102e2
Compare
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.
object_history_templateandchange_form_templateare the only unannotated attrs onSingletonModelAdmin. Unannotated, mypy infers them as barestr- butModelAdmintypes themClassVar[_TemplateForResponseT | None]via django-stubs.Subclass
SingletonModelAdminnext to anotherModelAdminsubclass that keeps the stub type and the two bases disagree:Annotating both to match the base clears it.