I just added `skip_pylint=True` to a lot of BUILD ...
# general
p
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
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
Oh, do I need to add to
python_tests()
? I thought it was only an option for
python_library()
h
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
hmm. โ” Do I need to have
python_library()
in the tests directories' BUILD files then?
h
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
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
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
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
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
I think so, because it says 700ish files instead of 1100ish files.
๐Ÿค˜ 1
h
Great!
p
Yes. That did it. ๐Ÿ™‚ I'm getting a much more reasonable set of issues now ๐Ÿ™‚
๐Ÿค˜ 1
h
Glad to hear. Please do keep the feedback and ideas coming ๐Ÿ™‚ this feature was a great suggestion!
p
And
./pants tailor
does add python_library again after I removed it. ๐Ÿ˜•
h
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
testing that ...
True. That worked just fine. I added the skip_pylint=True back anyway.
๐Ÿ‘ 1