Is there a way to have pants add `--builtins` for ...
# general
p
Is there a way to have pants add
--builtins
for all the registered targets when linting
pants-plugins/macros.py
?
Copy code
pants-plugins/macros.py:20:26: F821 undefined name 'python_artifact'
pants-plugins/macros.py:34:5: F821 undefined name 'python_distribution'
pants-plugins/macros.py:45:26: F821 undefined name 'python_artifact'
pants-plugins/macros.py:71:5: F821 undefined name 'python_distribution'
pants-plugins/macros.py:81:5: F821 undefined name 'shell_sources'
pants-plugins/macros.py:86:5: F821 undefined name 'resources'
^^ that's annoying 😛
b
Use a different Python resolve for your macro pyfiles
See https://www.pantsbuild.org/docs/plugins-overview#building-in-repo-plugins-with-pants (although you aren't writing a plugin, macros are like watered-down plugins)
w
i don’t think so, since they won’t be imported
b
Well, if they were imported that would be the other half of the issue! 😅
p
It is using my
pants-plugins
resolve.
1
b
Yeah whoops, RIP
p
And I've got
pants_requirements
pulling pantsbuild.pants into that resolve...
w
i think that currently you’d have to skip the relevant linters, and or skip that file entirely in
tailor
1
in the medium term… it’s possible that the implementation of macros should be adjusted such that they are declared in BUILD files
p
If anyone comes up with a a nice way to inject a list of targets as builtins, then maybe we could start running linters not just on the macros file, but on BUILD files...
b
Just this morning I was wondering what it'd be like if you could/had to
import
the targets in
BUILD
files. Similar to Bazel's
load
🤔
p
At a minimum, I'm going to want an intellij plugin that makes sure pycharm understands all of the valid symbols in BUILD files... 😉 But now I'm dreaming of the future.
I ignored those F821 issues in the macros file for now.
1
w
Just this morning I was wondering what it’d be like if you could/had to
import
the targets in
BUILD
files. Similar to Bazel’s
load
yea. now that we’ve introduced hierarchy via
__defaults__
though, i think that it’s possible that macros could be defined hierarchically in parent
BUILD
files as well… although whether that allows enough flexibility, i’m not sure.
(because
load
statements have always seemed too noisy to me, and having only a global preamble isn’t very scalable)
b
Yeah, theres pros/cons of each. I think the Pants way has the best pros-to-cons ratio 🙂
p
If you introduced macros into BUILD files, maybe they would take a different format.
Copy code
class my_macro(__macro__):
    def __call__():
or
Copy code
def __macros__():
    def my_macro(...):
        ...
👍 1
h
related to https://github.com/pantsbuild/pants/issues/14832. feel free to comment the issue you're having with macros