Skip to content

Fix test_lazy_choices_help failing on Python 3.14 - #1904

Open
vtino17 wants to merge 2 commits into
httpie:masterfrom
vtino17:fix/test-py314
Open

Fix test_lazy_choices_help failing on Python 3.14#1904
vtino17 wants to merge 2 commits into
httpie:masterfrom
vtino17:fix/test-py314

Conversation

@vtino17

@vtino17 vtino17 commented Jul 22, 2026

Copy link
Copy Markdown

Fixes #1641

Problem

Python 3.14 validates an argparse action's help immediately after constructing the action. That eager read caused LazyChoices.help to load choices during parser initialization, breaking the lazy contract.

Change

  • detect argparse's new _check_help validation path
  • skip exactly the initial eager help read
  • preserve normal lazy help generation when help is actually rendered

Validation

Tested with Python 3.14.6:

  • parser initialization does not call the choices getter
  • parser initialization does not call the help formatter
  • rendering help calls the formatter once with the loaded choices
  • code-style check: pass

vtino17 added 2 commits July 22, 2026 14:38
Initialize _help before super().__init__ to prevent argparse from
triggering getter() during Action initialization, which breaks the
lazy loading contract.

Fixes httpie#1641
@vtino17

vtino17 commented Aug 10, 2026

Copy link
Copy Markdown
Author

I corrected the Python 3.14 fix in commit 0685ac0. Python 3.14 validates action help after the action constructor returns, so initializing _help before super() was insufficient. The updated implementation skips exactly that initial eager validation when _check_help exists, while preserving lazy help generation. The existing regression expectations now pass under Python 3.14.6: neither the choices getter nor help formatter is called during parser initialization, and help rendering still calls the formatter once.

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.

test_lazy_choices_help fails on Python 3.14

1 participant