Add missing methods and fix inheritance in forms stubs#3153
Merged
sobolevn merged 1 commit intotypeddjango:masterfrom Mar 3, 2026
Merged
Add missing methods and fix inheritance in forms stubs#3153sobolevn merged 1 commit intotypeddjango:masterfrom
sobolevn merged 1 commit intotypeddjango:masterfrom
Conversation
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
UnknownPlatypus
approved these changes
Mar 2, 2026
sobolevn
approved these changes
Mar 3, 2026
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.
PR Summary
This PR fixes forms module stubs to match runtime. It adds the missing
__deepcopy__methods toField,ChoiceField,MultiValueField, andModelChoiceField. It addsAltersDatato the base classes ofBaseModelFormandBaseModelFormSetsosave_m2mis properly typed. It fixesBoundField.initialto use@cached_propertyinstead of@propertyand adds__html__toBoundWidgetandMedia. It correctsCheckboxSelectMultipleto inherit fromRadioSelectlike it does at runtime and movesid_for_labelup toRadioSelectwhere it's actually defined. It removes phantom attributes that don't exist at runtime (HiddenInput.choices,RadioSelect.can_add_related,ErrorList.field_name) and fixesInput.input_typeto bestr | Nonesince the base class has it asNone. Also it exportsALL_FIELDSfromdjango.forms, addsbound_field_classparam toBaseForm.__init__, addsrendererparam toformset_factory, and removes the bogusform_renderer/rendererparams fromBaseFormSet.__init__.Final note:
modelformset_factoryandinlineformset_factoryremain in the allowlist due to a stubtest false positive withtype[TypeVar]params. I opened a PR to python/mypy#20950.