Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions httpie/cli/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import sys
from typing import Any, Callable, Generic, Iterator, Iterable, Optional, TypeVar

T = TypeVar('T')
Expand Down Expand Up @@ -54,12 +55,26 @@ def load(self) -> T:
return self._obj

@property
def help(self) -> str:
def help(self) -> Optional[str]:
# Python 3.14's argparse calls ``_check_help`` during
# ``add_argument``, which accesses ``action.help``. We must not
# trigger the lazy getter at that point. Detect the validation
# phase by looking for ``_check_help`` on the call stack; in any
# other context (e.g. rendering ``--help``) we lazily compute the
# help string via ``help_formatter``.
if self._help is None and self.help_formatter is not None:
self._help = self.help_formatter(
self.load(),
isolation_mode=self.isolation_mode
)
frame = sys._getframe(1)
in_check_help = False
while frame is not None:
if frame.f_code.co_name == "_check_help":
in_check_help = True
break
frame = frame.f_back
if not in_check_help:
self._help = self.help_formatter(
self.load(),
isolation_mode=self.isolation_mode
)
return self._help

@help.setter
Expand Down
Loading