https://pantsbuild.org/ logo
#general
Title
# general
p

proud-dentist-22844

06/21/2022, 6:56 PM
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

bitter-ability-32190

06/21/2022, 6:57 PM
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

witty-crayon-22786

06/21/2022, 6:57 PM
i don’t think so, since they won’t be imported
b

bitter-ability-32190

06/21/2022, 6:58 PM
Well, if they were imported that would be the other half of the issue! 😅
p

proud-dentist-22844

06/21/2022, 6:58 PM
It is using my
pants-plugins
resolve.
1
b

bitter-ability-32190

06/21/2022, 6:58 PM
Yeah whoops, RIP
p

proud-dentist-22844

06/21/2022, 6:58 PM
And I've got
pants_requirements
pulling pantsbuild.pants into that resolve...
w

witty-crayon-22786

06/21/2022, 6:59 PM
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

proud-dentist-22844

06/21/2022, 7:00 PM
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

bitter-ability-32190

06/21/2022, 7:01 PM
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

proud-dentist-22844

06/21/2022, 7:12 PM
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

witty-crayon-22786

06/21/2022, 7:13 PM
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

bitter-ability-32190

06/21/2022, 7:15 PM
Yeah, theres pros/cons of each. I think the Pants way has the best pros-to-cons ratio 🙂
p

proud-dentist-22844

06/21/2022, 7:17 PM
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

hundreds-father-404

06/23/2022, 5:13 PM
related to https://github.com/pantsbuild/pants/issues/14832. feel free to comment the issue you're having with macros
7 Views