diff --git a/docs/notes/2.25.x.md b/docs/notes/2.25.x.md index d93b775a8e6..7171f0d53c8 100644 --- a/docs/notes/2.25.x.md +++ b/docs/notes/2.25.x.md @@ -21,7 +21,7 @@ Thank you to [Klayvio](https://www.klaviyo.com/) and [Normal Computing](https:// - Fixed a longstanding bug in the processing of [synthetic targets](https://www.pantsbuild.org/2.24/docs/writing-plugins/the-target-api/concepts#synthetic-targets-api). This fix has the side-effect of requiring immutability and hashability of scalar values in BUILD files, which was always assumed but not enforced. This may cause BUILD file parsing errors, if you have custom field types involving custom mutable data structures. See ([#21725](https://github.com/pantsbuild/pants/pull/21725)) for more. - [Fixed](https://github.com/pantsbuild/pants/pull/21665) bug where `pants --export-resolve= --export-py-generated-sources-in-resolve=` fails (see [#21659](https://github.com/pantsbuild/pants/issues/21659) for more info). - [Fixed](https://github.com/pantsbuild/pants/pull/21694) bug where an `archive` target is unable to produce a ZIP file with no extension (see [#21693](https://github.com/pantsbuild/pants/issues/21693) for more info). -- `extra_env_vars` (on many subsystems) now supports a generalised glob syntax using Python [fnmatch](https://docs.python.org/3/library/fnmatch.html) to construct patterns like `AWS_*`, `TF_*`, and `S2TESTS_*`. +- `[subprocess-environment].env_vars` and `extra_env_vars` (on many subsystems) now supports a generalised glob syntax using Python [fnmatch](https://docs.python.org/3/library/fnmatch.html) to construct patterns like `AWS_*`, `TF_*`, and `S2TESTS_*`. #### Remote Caching/Execution diff --git a/src/python/pants/engine/env_vars.py b/src/python/pants/engine/env_vars.py index 1290eada5aa..aa686b71d55 100644 --- a/src/python/pants/engine/env_vars.py +++ b/src/python/pants/engine/env_vars.py @@ -65,9 +65,7 @@ def check_and_set(name: str, value: Optional[str]): return FrozenDict(env_var_subset) def get_or_match(self, name_or_pattern: str) -> dict[str, str]: - """ - Get the value of an envvar if it has an exact match, otherwise all fnmatches. - """ + """Get the value of an envvar if it has an exact match, otherwise all fnmatches.""" if name_or_pattern in self: return {name_or_pattern: self.get(name_or_pattern)} return {k: v for k, v in self.items() if fnmatch.fnmatch(k, name_or_pattern)} diff --git a/src/python/pants/engine/environment_test.py b/src/python/pants/engine/environment_test.py index b579c24e000..5a13298c3bd 100644 --- a/src/python/pants/engine/environment_test.py +++ b/src/python/pants/engine/environment_test.py @@ -40,12 +40,14 @@ def test_invalid_variable() -> None: def test_envvar_fnmatch() -> None: - """Test fnmatch patterns correctly pull in all matching envvars""" + """Test fnmatch patterns correctly pull in all matching envvars.""" - pants_env = CompleteEnvironmentVars({ - "LETTER_C": "prefix_char_match", - "LETTER_PI": "prefix", - }) + pants_env = CompleteEnvironmentVars( + { + "LETTER_C": "prefix_char_match", + "LETTER_PI": "prefix", + } + ) char_match = pants_env.get_subset(["LETTER_?"]) assert char_match == {"LETTER_C": "prefix_char_match"}