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

Clarify how __defaults__ apply to target generators. #17493

Merged
Merged
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
19 changes: 19 additions & 0 deletions docs/markdown/Using Pants/concepts/targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,25 @@ python_tests(
)
```

> 🚧 Field default values for generated targets
>
> [Default field values](doc:targets#field-default-values) apply to target generators, _not_ to generated targets. For example, if you have:
>
> ```python
> __defaults__({python_test: {"timeout": 30}})
>
> python_tests(sources=["test_*.py", "!test_special.py"])
> python_test(name="special", source="test_special.py")
> ```
>
> Then the default `timeout` value will only apply to the "special" `python_test`, not to any of the targets generated by the `python_tests` target.
>
> To specify defaults for both generated and manually-written instances of a target, you must list the target generator in your `__defaults__` as well:
>
> ```python
> __defaults__({(python_test, python_tests): {"timeout": 30}})
> ```

The address for generated targets depends if the generated target is for first-party code or not:

[block:parameters]
Expand Down