Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add additional field 'fromfile' for options in the help-all goal output #17944

Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/python/pants/help/help_formatter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def _format_for_single_option(**kwargs):
choices=None,
comma_separated_choices=None,
value_history=OptionValueHistory((RankedValue(Rank.HARDCODED, None),)),
fromfile=False,
)
ohi = replace(ohi, **kwargs)
lines = HelpFormatter(
Expand Down
4 changes: 4 additions & 0 deletions src/python/pants/help/help_info_extracter.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class OptionHelpInfo:
removal_version: If deprecated: The version at which this option is to be removed.
removal_hint: If deprecated: The removal hint message registered for this option.
choices: If this option has a constrained set of choices, a tuple of the stringified choices.
fromfile: Supports reading the option value from a file when using `@filepath`.
"""

display_args: tuple[str, ...]
Expand All @@ -115,6 +116,7 @@ class OptionHelpInfo:
choices: tuple[str, ...] | None
comma_separated_choices: str | None
value_history: OptionValueHistory | None
fromfile: bool


@dataclass(frozen=True)
Expand Down Expand Up @@ -973,6 +975,7 @@ def get_option_help_info(self, args, kwargs):

target_field_name = f"{self._scope_prefix}_{option_field_name_for(args)}".replace("-", "_")
environment_aware = kwargs.get("environment_aware") is True
fromfile = kwargs.get("fromfile", False)

ret = OptionHelpInfo(
display_args=tuple(display_args),
Expand All @@ -992,5 +995,6 @@ def get_option_help_info(self, args, kwargs):
choices=choices,
comma_separated_choices=None if choices is None else ", ".join(choices),
value_history=None,
fromfile=fromfile,
)
return ret
5 changes: 5 additions & 0 deletions src/python/pants/help/help_info_extracter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ def fake_consumed_scopes_mapper(scope: str) -> Tuple[str, ...]:
},
"typ": int,
"default": 42,
"fromfile": False,
"help": "Option 1",
"deprecation_active": False,
"deprecated_message": None,
Expand All @@ -347,6 +348,7 @@ def fake_consumed_scopes_mapper(scope: str) -> Tuple[str, ...]:
},
"typ": LogLevel,
"default": LogLevel.INFO,
"fromfile": False,
"help": "Set the logging level.",
"deprecation_active": False,
"deprecated_message": None,
Expand All @@ -366,6 +368,7 @@ def fake_consumed_scopes_mapper(scope: str) -> Tuple[str, ...]:
"deprecation_active": False,
"display_args": ("--backend-packages=\"['<str>', '<str>', ...]\"",),
"env_var": "PANTS_BACKEND_PACKAGES",
"fromfile": False,
"help": "",
"removal_hint": None,
"removal_version": None,
Expand Down Expand Up @@ -395,6 +398,7 @@ def fake_consumed_scopes_mapper(scope: str) -> Tuple[str, ...]:
"deprecation_active": False,
"display_args": ("--pythonpath=\"['<str>', '<str>', ...]\"",),
"env_var": "PANTS_PYTHONPATH",
"fromfile": False,
"help": "",
"removal_hint": None,
"removal_version": None,
Expand Down Expand Up @@ -440,6 +444,7 @@ def fake_consumed_scopes_mapper(scope: str) -> Tuple[str, ...]:
},
"typ": bool,
"default": True,
"fromfile": False,
"help": "Option 2",
"deprecation_active": False,
"deprecated_message": None,
Expand Down