Skip to content

Type Meta.fields and local_fields as ColumnField - #109

Merged
davegaeddert merged 1 commit into
masterfrom
meta-fields-columnfield
Sep 4, 2026
Merged

Type Meta.fields and local_fields as ColumnField#109
davegaeddert merged 1 commit into
masterfrom
meta-fields-columnfield

Conversation

@davegaeddert

Copy link
Copy Markdown
Member

Follow-up to #103.

Meta.fields, concrete_fields, and local_concrete_fields were typed ImmutableList[Field] even though the only Field subclasses that aren't ColumnField are the abstract RelatedField and ManyToManyField, and M2M fields are routed to local_many_to_many in add_field. So every element really is a ColumnField, and #103 had to add an assert isinstance(f, ColumnField) inside clean_fields to read column attributes off it, next to a pre-existing one in Model.__init__.

  • Type local_fields, fields, concrete_fields, and local_concrete_fields as ColumnField.
  • Enforce the split once in add_field (raise TypeError for anything that is neither) instead of re-checking in every loop.
  • fields is now just an immutable copy of local_fields; the "generic relation" filter it carried from Django was dead code since no such field class exists here.
  • Drop the two isinstance(…, ColumnField) asserts in base.py and the equivalent skip in the convergence column comparison.
  • Widen QuerySet._update and UpdateQuery.add_update_fields to Sequence so a list[tuple[ColumnField, Any]] passes without an invariance error.

Type ignores 148 → 146, asserts 176 → 173.

Test plan

  • ./scripts/type-validate 26/26
  • ./scripts/test plain-postgres

@pullapprove5

pullapprove5 Bot commented Sep 4, 2026

Copy link
Copy Markdown
PASS: 1 review scope passed, 1 agent approved
Scope Progress
code 1/1

codex approved · 1 dismissed

View in PullApprove

Next steps:

@davegaeddert
davegaeddert merged commit 996c099 into master Sep 4, 2026
9 checks passed
@davegaeddert
davegaeddert deleted the meta-fields-columnfield branch September 4, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant