https://pantsbuild.org/ logo
#development
Title
# development
a

aloof-angle-91616

10/04/2020, 10:33 PM
it feels a little strange that
@rule
is in
src/python/pants/engine/rules.py
, whereas
Get
is in
.../engine/internal/rules.py
. is
Get
not part of the public API? it seems necessary to import in order to write a plugin, and i would feel weird writing
from pants.engine.internal import Get
if i was intending to use a stable API.
h

hundreds-father-404

10/04/2020, 11:22 PM
We intentionally re-export it from rules.py for that reason. Rules.py is already quite large, and we wanted to keep selectors code out of it But we don’t want to have selectors.py be a top level thing, because it resulted in lots of extra import boilerplate Instead, you do something like this: from pants.engine.rules import Get, rule
a

aloof-angle-91616

10/04/2020, 11:23 PM
ok but it was
from pants.engine.selectors import Get
before
ah
ok
i understand, so that we can reduce the number of imports
h

hundreds-father-404

10/04/2020, 11:23 PM
Indeed. And we wanted to consolidate imports
👖 1
coke
a

aloof-angle-91616

10/04/2020, 11:23 PM
it's still a little weird to me why that file is in
internals/
i can kinda get the reasoning
not really a concern enough to change it
h

hundreds-father-404

10/04/2020, 11:25 PM
Because putting the implementation in rules.py seemed like it might make that even file even more unwieldy. Selectors.py is large very very large due to type hint boilerplate But we could have put the implementation in rules.py to avoid this re-export weirdness
a

aloof-angle-91616

10/04/2020, 11:25 PM
i was thinking rather just moving the file
selectors.py
as-is out of the
internals/
subdirectory
h

hundreds-father-404

10/05/2020, 12:01 AM
We solely want engine/ to have things that you directly import, though. It’s the public API. My concern is having both rules.py and selectors.py might be confusing which to use. At that point, I’d probably advocate only having the top level selectors.py, which brings us back to square 1 (is that a phrase??)
a

aloof-angle-91616

10/05/2020, 3:33 AM
yes! back to square 1
i just added something else to that file so we can re evaluate in the diff