Skip to content

Commit

Permalink
doc tweak.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaos committed Mar 7, 2024
1 parent 43bcfb8 commit 6f54cc0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
20 changes: 0 additions & 20 deletions docs/docs/using-pants/key-concepts/targets-and-build-files.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -323,26 +323,6 @@ python_tests(
)
```
:::caution Field default values for generated targets
[Default field values](./targets-and-build-files.mdx#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:
| Generated target type | Generated address syntax |
Expand Down
7 changes: 7 additions & 0 deletions src/python/pants/engine/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,13 @@ class TargetGenerator(Target):
"""

# The generated Target class.
#
# If this is not provided, consider checking for the default values that applies to the target
# types being generated manually. The applicable defaults are available on the `AddressFamily`
# which you can get using:
#
# family = await Get(AddressFamily, AddressFamilyDir(address.spec_path))
# target_defaults = family.defaults.get(MyTarget.alias, {})
generated_target_cls: ClassVar[type[Target]]

# Fields which have their values copied from the generator Target to the generated Target.
Expand Down

0 comments on commit 6f54cc0

Please sign in to comment.