fresh-cat-90827
01/07/2023, 5:05 AMpreamble
which isn't yet used it seems. 🧵fresh-cat-90827
01/07/2023, 5:06 AM[preamble]
template_by_globs = "@build-support/preambles/config.yaml"
in the pants.toml
, I think this was supposed to be [preamble].config
?fresh-cat-90827
01/07/2023, 5:08 AMconfig
property declared for the subsystem in contrast to other subsystems such as [mypy]
or [pytest]
, so JSON schema is incomplete 🙂fresh-cat-90827
01/07/2023, 5:09 AMbitter-ability-32190
01/07/2023, 8:00 AMbitter-ability-32190
01/07/2023, 8:00 AMfresh-cat-90827
01/07/2023, 8:04 AMbitter-ability-32190
01/07/2023, 8:20 AMbitter-ability-32190
01/07/2023, 8:21 AMcurved-television-6568
01/07/2023, 2:11 PM"@…
is significant here…bitter-ability-32190
01/07/2023, 2:13 PMbitter-ability-32190
01/07/2023, 2:13 PM@
fresh-cat-90827
01/07/2023, 3:08 PM@
notation; that's what's used in the https://www.pantsbuild.org/docs/reference-regex-lint as well. It's the type of the option as seen by the Pants help-all
goal:
{
"choices": null,
"comma_separated_choices": null,
"comma_separated_display_args": "--preamble-template-by-globs=\"{'key1': val1, 'key2': val2, ...}\"",
"config_key": "template_by_globs",
"default": {},
"deprecated_message": null,
"deprecation_active": false,
"display_args": [
"--preamble-template-by-globs=\"{'key1': val1, 'key2': val2, ...}\""
],
"env_var": "PANTS_PREAMBLE_TEMPLATE_BY_GLOBS",
"help": "Which preamble template to use based on the path globs (relative to the build root).\n\nExample:\n\n {\n '*.rs': '// Copyright (c) $year\n// Line 2 '\n '*.py:!__init__.py': '# Copyright (c) $year\n# Line 2 ',\n }\n\nIt might be helpful to load this config from a JSON or YAML file. To do that, set `[preamble].config = '@path/to/config.yaml'`, for example.",
"removal_hint": null,
"removal_version": null,
"scoped_cmd_line_args": [
"--preamble-template-by-globs"
],
"target_field_name": null,
"typ": "dict",
"unscoped_cmd_line_args": [
"--template-by-globs"
],
As far as JSON schema concerned, the property is supposed to be an object (the Python dict
). But clearly it can also be a string (with the @
) that will load the data from a file turning it into a dict
at runtimecurved-television-6568
01/07/2023, 3:14 PMfromfile
property of this option is not reflected here, as not all options support it we can’t even assume that is an option for all.. er, options 😉fresh-cat-90827
01/07/2023, 3:18 PMall-help
output) that an option could be of multiple types (a dict and a string in this case)? 😕bitter-ability-32190
01/07/2023, 3:18 PMcurved-television-6568
01/07/2023, 3:22 PMfresh-cat-90827
01/07/2023, 3:23 PMfresh-cat-90827
01/07/2023, 3:24 PMthere’s a way to include the support for fromfile syntax in the all-help info output…perfect, let me fire up a ticket...
curved-television-6568
01/07/2023, 3:26 PM--preamble-template-by-globs="{'key1': val1, 'key2': val2, ...}"
PANTS_PREAMBLE_TEMPLATE_BY_GLOBS
template_by_globs
default: {}
current value: {
"**/*.py:!**/__init__.py:**/BUILD:**/BUILD.*": "# Copyright $year Pants project contributors (see CONTRIBUTORS.md).\n# Licensed under the Apache License, Version 2.0 (see LICENSE).\n",
"**/*.rs": "// Copyright $year Pants project contributors (see CONTRIBUTORS.md).\n// Licensed under the Apache License, Version 2.0 (see LICENSE).\n"
} (from pants.toml)
-- FROMFILE: True
Which preamble template to use based on the path globs (relative to the build root).
Example:
diff --git a/src/python/pants/help/help_formatter.py b/src/python/pants/help/help_formatter.py
index 699a7bb2d..70a38f80b 100644
--- a/src/python/pants/help/help_formatter.py
+++ b/src/python/pants/help/help_formatter.py
@@ -148,6 +148,7 @@ class HelpFormatter(MaybeColor):
*default_lines,
*curr_value_lines,
*value_derivation_lines,
+ f"-- FROMFILE: {ohi.fromfile}",
*deprecated_lines,
*description_lines,
]
diff --git a/src/python/pants/help/help_info_extracter.py b/src/python/pants/help/help_info_extracter.py
index e5a235a41..da386d90c 100644
--- a/src/python/pants/help/help_info_extracter.py
+++ b/src/python/pants/help/help_info_extracter.py
@@ -115,7 +115,7 @@ class OptionHelpInfo:
choices: tuple[str, ...] | None
comma_separated_choices: str | None
value_history: OptionValueHistory | None
-
+ fromfile: bool
@dataclass(frozen=True)
class OptionScopeHelpInfo:
@@ -974,6 +974,8 @@ class HelpInfoExtracter:
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),
comma_separated_display_args=", ".join(display_args),
@@ -992,5 +994,6 @@ class HelpInfoExtracter:
choices=choices,
comma_separated_choices=None if choices is None else ", ".join(choices),
value_history=None,
+ fromfile=fromfile,
)
return ret
bitter-ability-32190
01/07/2023, 3:27 PMbitter-ability-32190
01/07/2023, 3:28 PMfresh-cat-90827
01/07/2023, 3:29 PM.add
syntax as in:
extra_requirements.add = [
"mypy-typing-asserts",
"strawberry-graphql>=0.95.1,<0.96",
]
is considered a violation: {"add":["mypy-typing-asserts","strawberry-graphql>=0.95.1,<0.96"]} is not of type "array"
fresh-cat-90827
01/07/2023, 3:29 PM.add
- legal thing, just a different interpretation lolbitter-ability-32190
01/07/2023, 3:51 PMfresh-cat-90827
01/07/2023, 3:52 PMfresh-cat-90827
01/07/2023, 3:57 PM