Skip to content

[WTForms] Accept lazy strings for labels, descriptions and messages - #16507

Merged
srittau merged 2 commits into
python:mainfrom
Bortlesboat:wtforms-lazy-strings
Nov 3, 2026
Merged

srittau merged 2 commits into
python:mainfrom
Bortlesboat:wtforms-lazy-strings

Conversation

@Bortlesboat

Copy link
Copy Markdown
Contributor

Closes #16489.

Adds a private _LazyString protocol (__html__ + __mod__) and accepts it alongside str for field labels/descriptions, Label text, validator messages, and ValidationError/StopValidation. errors collections stay str to avoid breaking code that reads them back.

Upstream: Label.__call__ renders via markupsafe.escape(); validators such as Length %-format their message.

Agent: Claude Code

@github-actions

This comment has been minimized.

# Conflicts:
#	stubs/WTForms/wtforms/fields/choices.pyi
#	stubs/WTForms/wtforms/fields/datetime.pyi
#	stubs/WTForms/wtforms/fields/form.pyi
#	stubs/WTForms/wtforms/fields/list.pyi
#	stubs/WTForms/wtforms/fields/numeric.pyi
#	stubs/WTForms/wtforms/fields/simple.pyi
#	stubs/WTForms/wtforms/validators.pyi
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

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

@srittau
srittau merged commit 6e34429 into python:main Nov 3, 2026
74 checks passed
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.

[WTForms] Stubs reject lazy strings for labels, descriptions, and validation messages

2 participants