Infer a `ModelForm`'s model type from `Meta.model` #3841
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.33) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.33 · 151 lines diff across 1 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.301
Real PR Conversation Timeline
1 comments
"Review active on #3841"
general
weight: 0.35
sobolevn
I have made things!
Related issues
Fixes #3678
when a
ModelFormsubclass setsclass Meta: model = Articlebut leaves out the type argument, mypy sees it asModelForm[Any]. that meansform.instanceandform.save()both come back asAny.the plugin already handles the form's
Metain the base class hook, so I added a step there that readsMeta.modeland fills inModelForm[Article]when the argument was left out. subclasses pick it up from their parent. if you write the argument yourself (evenModelForm[Any]) it stays as written, and withdisallow_any_genericsthe missing type argument error stays too, same as managers and querysets.this only changes the mypy plugin. the issue was reported with ty, which doesn't run plugins, so there
forms.ModelForm[MyModel]is still the way to go.tested with two new cases in
tests/typecheck/test_forms.yml, the fullpytestrun,mypy ext scripts mypy_django_plugin,mypy testsand ruffAI Policy