hmmm is there a way to specify that some dependenc...
# general
a
hmmm is there a way to specify that some dependencies shouldn’t regularly be inferred? I would kind of not like to include everything that is being used for type checking
h
Hey Nate! The only ways I know how to do this are: 1. Exclude via
!
at each call site. Ack that's tedious 2. Intentionally introduce a new thing that results in ambiguity. Like, add a second version of the third-party dependency so that it's ambiguous and you have to explicitly opt-in to including the dep. But that is also kind of tedious and will result in lots of warnings about ambiguity, which you may want to avoid I'm wondering more about your motivation - how come you don't want some things included?
a
ah how precisely do i exclude via
!
at each call site? The context here is that we have a class that has attributes with types if imported eventually pull in the entire code base. But those attributes are never set or accessed in that file they are just declared so mypy doesn’t yell at us later
h
a
ah thank you
❤️ 1
oh to do this for an individual file I would need individual targets for each dependent file?
h
Dependency inference defaults to "file dependencies". Meaning, if you have a single target in a BUILD file with N files in its
sources
, Pants creates a target per file for you automatically Run
./pants dependencies path/to/file_with_import_you_want_to_ignore.py
, and you should see a file like
path/to/file_to_ignore.py
or
path/to/file_to_ignore.py:lib
. Copy that and put it with
!
in the prefix in the
dependencies
for the call site target. Does that make sense?
a
yeah I think so! thanks!
❤️ 1