Skip to content

[WTForms] Update stubs for 3.3.0 - #16604

Open
Daverball wants to merge 5 commits into
python:mainfrom
Daverball:wtforms-3.3
Open

Daverball wants to merge 5 commits into
python:mainfrom
Daverball:wtforms-3.3

Conversation

@Daverball

@Daverball Daverball commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Release: https://pypi.org/pypi/WTForms/3.3.0
Repository: https://github.com/pallets-eco/wtforms
Typeshed stubs: https://github.com/python/typeshed/tree/main/stubs/WTForms
Changelog: https://wtforms.readthedocs.io/changes
Diff: pallets-eco/wtforms@3.2.2...3.3.0

Fixes: #16605

Most of the major changes are related to how choices are passed to select fields, the old style has been deprecated and will be removed in 3.4.0, this makes the types a little unwieldy now, but they should simplify again later.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Daverball

This comment was marked as resolved.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Comment on lines 75 to +79
def iter_choices(self) -> Iterator[_FullChoice]: ...
def _iter_choices_normalized(self) -> Iterator[Choice]: ...
def has_groups(self) -> bool: ...
def iter_groups(self) -> Iterator[_FullGroupedChoices]: ...
def _iter_groups_normalized(self) -> Iterator[tuple[str, list[Choice]]]: ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little conflicted about exposing these internal normalization helpers, that are likely to disappear in 3.4.0

Yielding a plain tuple is deprecated and the Select widget will check for that and emit a DeprecationWarning, but during this deprecation period there's no guarantees about whether or not you will get a plain tuple, or the Choice named tuple if you're using custom subclasses that haven't been updated yet.

So either we change iter_choices and iter_groups to the new signatures and you get a hard type error for something that's supposed to be just a deprecation warning and a false negative on widgets that expect to get Choice objects, when in fact they still could receive plain tuples, or we leave it like this and you cannot update your own Widgets to rely on the presence of the named Choice attributes, without exposing this internal helper, or doing the conversion yourself.

This branch has not been deployed

No deployments
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