proud-dentist-22844
05/12/2021, 4:00 AMskip_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/aa2ba3a2bb8540fbc80f82d644ba2c7ffad2d3a0proud-dentist-22844
05/12/2021, 4:01 AMhundreds-father-404
05/12/2021, 4:02 AMpython_tests()
targets as well?
(Sorry, we know this is very stinted and not super intuitive. Again, we really want to re-envision targets)proud-dentist-22844
05/12/2021, 4:10 AMpython_tests()
? I thought it was only an option for python_library()
hundreds-father-404
05/12/2021, 4:11 AMpython_library()
is metadata for non-test Python files, whereas python_tests
is metadata for test filesproud-dentist-22844
05/12/2021, 4:12 AMpython_library()
in the tests directories' BUILD files then?hundreds-father-404
05/12/2021, 4:15 AM__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 fileproud-dentist-22844
05/12/2021, 4:17 AM__init__.py
in the tests directories right?proud-dentist-22844
05/12/2021, 4:20 AM__init__.py
files under tests have any content.hundreds-father-404
05/12/2021, 4:20 AMsources
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-ownshundreds-father-404
05/12/2021, 4:21 AMNone 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 backproud-dentist-22844
05/12/2021, 4:23 AM[python-infer].inits = true
because in the code (not the tests) init files sometimes DO have code in them.proud-dentist-22844
05/12/2021, 4:23 AMhundreds-father-404
05/12/2021, 4:33 AM./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 themhundreds-father-404
05/12/2021, 4:34 AMskip_pylint=True
to the python_tests
targets working?proud-dentist-22844
05/12/2021, 4:41 AMhundreds-father-404
05/12/2021, 4:42 AMproud-dentist-22844
05/12/2021, 4:43 AMhundreds-father-404
05/12/2021, 4:45 AMproud-dentist-22844
05/12/2021, 4:45 AM./pants tailor
does add python_library again after I removed it. ๐hundreds-father-404
05/12/2021, 4:46 AMskip_pylint=True
to those python_library
targets because it doesn't matter if you run it over those empty init.py files or notproud-dentist-22844
05/12/2021, 4:47 AMproud-dentist-22844
05/12/2021, 4:54 AM