cool-easter-32542
06/03/2025, 2:39 PM__defaults__ with a macro and an environment in the same BUILD file results in an InvalidFieldTypeException.
If the __defaults__ block is moved to a BUILD file in a subdirectory of the project, it works without an error.
BUILD file example:
__defaults__(
{
python_test: dict(
extra_env_vars=default_env_vars()
)
},
)
python_requirements(
name="root",
)
python_sources()
docker_environment(
name="test-docker-environment",
image="python:3.12"
)
Results in Error: `` `InvalidFieldTypeException: The 'extra_env_vars' field in target //#__defaults__ must be an iterable of strings (e.g. a list of strings), but was default_env_vars() with type <unrecognized symbol>\. ``
Pants version
2.25.1, 2.27.0rc0 and 2.28.0.dev2
OS
WSL on Windows
Additional info
pants.toml relevant parts:
[GLOBAL]
backend_packages = [
'pants.backend.python',
'pants.backend.docker',
]
build_file_prelude_globs = ["macros.py"]
[environments-preview.names]
test-environment="//:test-docker-environment"
macros.py file:
def default_env_vars(**kwargs):
envs = [
'HAS_TO_EXIST',
]
return envs
pantsbuild/pants