Skip to content

MultipleChoiceField: align stubs with DRF 3.17 list-based API - #995

Draft
intgr with Copilot wants to merge 2 commits into
masterfrom
copilot/multiplechoicefield-list-values
Draft

MultipleChoiceField: align stubs with DRF 3.17 list-based API#995
intgr with Copilot wants to merge 2 commits into
masterfrom
copilot/multiplechoicefield-list-values

Conversation

Copilot AI commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

I have made things!

DRF 3.17 (encode/django-rest-framework#9735) switched MultipleChoiceField from set-based to list-based semantics, but the stubs still expected set for default/initial and inherited ChoiceField.to_internal_value returning str.

  • rest_framework-stubs/fields.pyiMultipleChoiceField:
    • default / initial now accept Sequence[...] instead of set[...].
    • Override to_internal_value to return list[Any].
    • Generic params updated: _VTlist[Any], _RPlist[str | tuple[str | int, str | int]].
  • tests/typecheck/test_fields.ymlMultipleChoiceField_default updated: list literals/callables now accepted, set literals/callables flagged.
# Now valid
MultipleChoiceField(choices=[1], default=[1])
MultipleChoiceField(choices=[1], default=lambda: [1])

# Now rejected (was previously accepted)
MultipleChoiceField(choices=[1], default={1})

Related issues

Copilot AI changed the title [WIP] Fix MultipleChoiceField to accept list values in DRF 3.17 MultipleChoiceField: align stubs with DRF 3.17 list-based API Jun 11, 2026
Copilot AI requested a review from intgr June 11, 2026 20:14
Copilot finished work on behalf of intgr June 11, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

MultipleChoiceField should take/return list values in DRF 3.17

2 participants