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

proud-dentist-22844

05/12/2021, 4:00 AM
I just added
skip_pylint=True
to a lot of BUILD files, but pylint is still reporting errors on py files in those directories. Any idea what I'm missing? https://github.com/st2sandbox/st2/commit/aa2ba3a2bb8540fbc80f82d644ba2c7ffad2d3a0
๐Ÿค” 1
It's no longer reporting issues with setup.py files, but it's still reporting issues in a lot of tests/ directory files. ๐Ÿ˜•
h

hundreds-father-404

05/12/2021, 4:02 AM
Oh, did you add to the
python_tests()
targets as well? (Sorry, we know this is very stinted and not super intuitive. Again, we really want to re-envision targets)
p

proud-dentist-22844

05/12/2021, 4:10 AM
Oh, do I need to add to
python_tests()
? I thought it was only an option for
python_library()
h

hundreds-father-404

05/12/2021, 4:11 AM
Yeah, if you want to skip running on the test files too.
python_library()
is metadata for non-test Python files, whereas
python_tests
is metadata for test files
p

proud-dentist-22844

05/12/2021, 4:12 AM
hmm. โ” Do I need to have
python_library()
in the tests directories' BUILD files then?
h

hundreds-father-404

05/12/2021, 4:15 AM
Depends if your
__init__.py
file has content in it or not.
python_library()
will give metadata for
__init__.py
because it's technically not a test file But if your
__init__.py
files are completely empty, then you can skip having those
python_library
targets for them - Pants will still look for the files and include them in chroots no matter what Otherwise, you need the target so Pants can do things like dependency inference for the file
p

proud-dentist-22844

05/12/2021, 4:17 AM
And in this case, you're only talking about
__init__.py
in the tests directories right?
Cool. None of the
__init__.py
files under tests have any content.
h

hundreds-father-404

05/12/2021, 4:20 AM
Yeah, unless you overrode the
sources
field, each target only gives metadata for the directory it's located in. So the
python_library
for tests/my_project/BUILD` would describe the metadata for files like
tests/my_project/__init__.py
and
tests/my_project/some_test_util.py
, but not
tests/my_project/test_app.py
The
./pants filedeps
goal might make this a little more clear (Assuming you used
./pants tailor
) try running
./pants filedeps tests/my_project
and
./pants filedeps tests/my_project:tests
. https://www.pantsbuild.org/docs/project-introspection#filedeps---find-which-files-a-target-owns
None of theย init.pyย files under tests have any content.
Cool, so you could technically delete those
python_library
targets if you wanted to. Although it's annoying that
./pants tailor
would keep trying to add them back
p

proud-dentist-22844

05/12/2021, 4:23 AM
I do have
[python-infer].inits = true
because in the code (not the tests) init files sometimes DO have code in them.
Maybe that's why?
h

hundreds-father-404

05/12/2021, 4:33 AM
Got it. Although,
./pants tailor
isn't that fancy to look at that option. Instead, it simply sees there is a file
__init__.py
that matches the default sources for `python_library`:
(*.py, !*_test.py, !test_*.py, !tests.py, !conftest.py)
. Regardless of
[python-infer].inits
,
./pants tailor
will generate those targets - so probably simpler for you to keep them
Is adding
skip_pylint=True
to the
python_tests
targets working?
p

proud-dentist-22844

05/12/2021, 4:41 AM
I think so, because it says 700ish files instead of 1100ish files.
๐Ÿค˜ 1
h

hundreds-father-404

05/12/2021, 4:42 AM
Great!
p

proud-dentist-22844

05/12/2021, 4:43 AM
Yes. That did it. ๐Ÿ™‚ I'm getting a much more reasonable set of issues now ๐Ÿ™‚
๐Ÿค˜ 1
h

hundreds-father-404

05/12/2021, 4:45 AM
Glad to hear. Please do keep the feedback and ideas coming ๐Ÿ™‚ this feature was a great suggestion!
p

proud-dentist-22844

05/12/2021, 4:45 AM
And
./pants tailor
does add python_library again after I removed it. ๐Ÿ˜•
h

hundreds-father-404

05/12/2021, 4:46 AM
Yeah ๐Ÿ˜ I'm not sure what the story should be for how to opt out of generating certain targets Fwit, you don't need to worry about adding
skip_pylint=True
to those
python_library
targets because it doesn't matter if you run it over those empty init.py files or not
p

proud-dentist-22844

05/12/2021, 4:47 AM
testing that ...
True. That worked just fine. I added the skip_pylint=True back anyway.
๐Ÿ‘ 1
7 Views