https://pantsbuild.org/ logo
f

freezing-lamp-12123

10/25/2022, 7:19 PM
one of the most confusing (as a python beginner too) aspect of trying to grok pants is how the mixin/dependency injection works, and knowing what i can “request” in the conrext of writing a goal/rule — are there any (heh…), uhm — rules around that behaviour? how do i set myself up for success as a first time pants plugin developer?
w

witty-crayon-22786

10/25/2022, 7:24 PM
yea, that definitely takes some getting used to.
the actual extension points for plugins are `@union`s: so if you want to write a plugin, you’ll generally be implementing a member of a
@union
: https://www.pantsbuild.org/docs/rules-api-unions
(not “creating a `@union`”: just “implementing a `@union`”)
f

freezing-lamp-12123

10/25/2022, 7:29 PM
🤔 — yeah, i’ve been reading most of thr conceptual parts of the docs — but probably takes a couple of good thorough reads before just getting 10% of it to stick 😂
thanks for the pointers
b

busy-vase-39202

10/25/2022, 7:49 PM
It would be really useful to raise your initial questions from reading it, rather than just trying to sort it out alone. Hearing how a novice interprets it, and what would benefit from further clarification, can help the team improve that doc for you and everyone else too,
c

curved-television-6568

10/25/2022, 7:49 PM
Also, for discoverability, the cli help has rather comprehensive information about the various rules and api types as well.
Example:
Copy code
╰─❯ ./pants help SyntheticTargetsRequest

`pants.engine.internals.synthetic_targets.SyntheticTargetsRequest` api type
---------------------------------------------------------------------------

Union members of the `SyntheticTargetsRequest` should implement a rule returning an instance
of a `SyntheticAddressMaps`.

activated by : pants.engine.internals.synthetic_targets
union members: PythonSyntheticLockfileTargetsRequest

Include API types and rules dependency information by running `./pants help-advanced pants.engine.internals.synthetic_targets.SyntheticTargetsRequest`.
and
./pants help api-types
gives a long list of stuff.. 😛
h

happy-kitchen-89482

10/25/2022, 7:52 PM
Yeah the API is very powerful, but with great power comes great inscrutability, at the moment… We want to write more docs/guides/examples for this, when we have the time and resources
Sorry it’s been a grind
w

witty-crayon-22786

10/25/2022, 7:52 PM
@curved-television-6568: ah, yea! those are great. i’m not sure that the docs mention them
c

curved-television-6568

10/25/2022, 7:53 PM
you’re right, we’ve likely overlooked that part 😅
w

witty-crayon-22786

10/25/2022, 7:54 PM
thanks for adding that.
🙏 1
b

busy-vase-39202

10/25/2022, 7:56 PM
If that's not in the docs, would someone please open a ticket to add it? That's a heck of a tip.
It'd also make a nice blog post, if anyone is interested in promoting that tip further.
3 Views