From e16be71faaa70213ea86158ae3f3d5ee7e1b31db Mon Sep 17 00:00:00 2001 From: vtino17 Date: Wed, 22 Jul 2026 14:38:49 +0700 Subject: [PATCH 1/2] Fix test_lazy_choices_help failing on Python 3.14 Initialize _help before super().__init__ to prevent argparse from triggering getter() during Action initialization, which breaks the lazy loading contract. Fixes #1641 --- httpie/cli/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httpie/cli/utils.py b/httpie/cli/utils.py index ad27da37f7..8726aadd53 100644 --- a/httpie/cli/utils.py +++ b/httpie/cli/utils.py @@ -41,8 +41,10 @@ def __init__( self.sort = sort self.cache = cache self.isolation_mode = isolation_mode - self._help: Optional[str] = None self._obj: Optional[Iterable[T]] = None + # Initialize before super().__init__ to prevent argparse + # from triggering getter() during __init__ on Python 3.14 + self._help = "" super().__init__(*args, **kwargs) self.choices = self From 0685ac053dafd52776da3fdcbfe66e579cbc8ca3 Mon Sep 17 00:00:00 2001 From: Valentino Saputra Date: Tue, 11 Aug 2026 06:17:43 +0700 Subject: [PATCH 2/2] fix: defer Python 3.14 argparse validation --- httpie/cli/utils.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/httpie/cli/utils.py b/httpie/cli/utils.py index 8726aadd53..5cab9926c9 100644 --- a/httpie/cli/utils.py +++ b/httpie/cli/utils.py @@ -42,9 +42,12 @@ def __init__( self.cache = cache self.isolation_mode = isolation_mode self._obj: Optional[Iterable[T]] = None - # Initialize before super().__init__ to prevent argparse - # from triggering getter() during __init__ on Python 3.14 - self._help = "" + # Python 3.14 validates an action's help immediately after creating it. + # Skip that eager read so lazy help remains lazy until it is rendered. + self._skip_initial_help_validation = hasattr( + argparse._ActionsContainer, + '_check_help' + ) super().__init__(*args, **kwargs) self.choices = self @@ -56,7 +59,10 @@ def load(self) -> T: return self._obj @property - def help(self) -> str: + def help(self) -> Optional[str]: + if self._skip_initial_help_validation: + self._skip_initial_help_validation = False + return None if self._help is None and self.help_formatter is not None: self._help = self.help_formatter( self.load(),