gentle-flower-25372
04/10/2024, 12:25 AM__init__.py
say...
# module_a/sub_dir/__init__.py
from module_a.sub_dir.other_thing import other_thing
then
# module_b/thing.py
from module_a.sub_dir import other_thing
pants is failing to infer the deps in module_b/thing.py
I tried setting [python-infer].init_files
to always
with no luck.
[python-infer]
init_files = "always"
broad-processor-92400
04/10/2024, 11:58 AMgentle-flower-25372
04/10/2024, 1:56 PM__init__.py
that can't be inferred.gentle-flower-25372
04/10/2024, 2:10 PM# module_a/sub_dir/__init__.py
MY_CONST = "hello"
# module_b/thing.py
from module_a.sub_dir import MY_CONST
gentle-flower-25372
04/10/2024, 2:42 PMpython_sources(
name="my_name",
dependencies=[":my_name"],
)
gentle-flower-25372
04/10/2024, 2:43 PM__init__.py
into it's own python_source target. This broke things:
python_source(
name="init",
source="__init__.py",
dependencies=[":my_name"],
)
python_sources(
name="my_name",
)
broad-processor-92400
04/10/2024, 9:11 PMmy_name
sources
to exclude __init__.py
. Something like sources = [“*.py”, “!__init__.py”]
• Have just one target and use overrides
to customise the file(s) that need it: https://www.pantsbuild.org/2.19/docs/using-pants/key-concepts/targets-and-build-files#target-generation
I recommend the secondgentle-flower-25372
04/10/2024, 10:13 PMbroad-processor-92400
04/10/2024, 11:38 PM