rich-kite-32423
12/31/2022, 6:16 PMpython_test
target for each file in the sources
field."
Should that be sources
"argument", rather than "field"? I've seen this in a number of places and it had me hunting for a "sources field" until I guessed that it probably meant the function argument.fast-nail-55400
12/31/2022, 7:45 PMpython_tests
is actually a target; just a special kind of target: “generator target”fast-nail-55400
12/31/2022, 7:45 PMsources
is actually a field.curved-television-6568
12/31/2022, 8:12 PMsources
section: https://www.pantsbuild.org/docs/reference-python_tests#codesourcescoderich-kite-32423
12/31/2022, 8:37 PMsources
section and that's how I figured out what was going on.
So you're saying python_tests
is not a function? It's usage inside BUILD
sure reads like a function call.fast-nail-55400
12/31/2022, 8:46 PMpython_tests
have a name
and can be referenced via a target address just like any other target type.bitter-ability-32190
12/31/2022, 10:14 PMfast-nail-55400
01/01/2023, 6:14 PMpython_tests
can look like a function call to a developer, they behave semantically like declarations. The declarations have names and are part of the build graph just like any other target, If we start to document them as "functions," then a user might expect them to be something they can call which is not the case.
A similar issue exists in plugin code. Plugin code use async ... await
syntax to represent invoking other rules. One reasonable first interpretation is that it is an RPC call, but in fact Pants uses the async ... await
syntax to represent a query to the Pants rule engine. That query is deduplicated and cached as applicable. Even though it looks like an RPC call, it semantically behaves like a query to an expert system.fast-nail-55400
01/01/2023, 6:16 PMbitter-ability-32190
01/01/2023, 6:21 PMsources
field inherits from type PythonSourceField
. Right now that is meaningless to the user because it's unclear which targets have fields of that typerich-kite-32423
01/02/2023, 3:59 AMcurved-television-6568
01/02/2023, 4:28 AMa user might expect them to be something they can call which is not the case.what do you mean with this? From a macro function for instance, you can declare any number of targets by “calling them”..
def my_macro(some, inputs):
# do stuff
files(name=f"{inputs}-files")
python_sources(name=f"{some}-sources")
...
to me it makes sense to view targets and fields as functions and arguments if that helps (as that is how it is implemented any way, really..)bitter-ability-32190
01/02/2023, 12:12 PMbitter-ability-32190
01/02/2023, 12:13 PMbusy-vase-39202
01/02/2023, 12:44 PMbitter-ability-32190
01/02/2023, 1:37 PM@attr.s
class python_source:
name: str
source: PythonSourceField = attr.field(..., converter=from_str)
...
bitter-ability-32190
01/02/2023, 2:01 PMbitter-ability-32190
01/02/2023, 7:22 PM# today...
python_source(
run_goal_use_sandbox=True,
)
# would be nice
python_source(
run.use_sandbox=True
)
bitter-ability-32190
01/02/2023, 7:25 PMcurved-television-6568
01/02/2023, 10:29 PMbusy-vase-39202
01/03/2023, 4:12 PMbitter-ability-32190
01/03/2023, 4:14 PMbusy-vase-39202
01/03/2023, 4:29 PMbitter-ability-32190
01/03/2023, 4:30 PMbusy-vase-39202
01/03/2023, 4:55 PM