it feels a little strange that `@rule` is in `src/...
# development
a
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
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
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
Indeed. And we wanted to consolidate imports
👖 1
coke
a
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
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
i was thinking rather just moving the file
selectors.py
as-is out of the
internals/
subdirectory
h
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
yes! back to square 1
i just added something else to that file so we can re evaluate in the diff