Just spent a couple hours debugging, so I'll share...
# general
s
Just spent a couple hours debugging, so I'll share a TIL: Pants infers type stub dependencies differently than real dependencies, which can lead to confusing behavior during inference. In one python file, we have
import sqlalchemy
, and pants printed the following warning, even though the first target in the array is a perfect match (same name, same resolve, and same source root).
Copy code
14:33:11.60 [WARN] The target common/file.py imports `sqlalchemy`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['common:poetry#sqlalchemy', 'libs/libA:poetry#sqlalchemy-stubs@resolve=common', 'libs/libB:poetry#sqlalchemy-stubs@resolve=common'].
Right here, pants applies the
by_source_root
logic against each category of dependencies separately. Since our
common:poetry
doesn't declare a dependency on
sqlalchemy-stubs
but files in other source roots in our repo do, pants thinks the dependency is ambiguous. I don't know if this should be considered a bug? It sort of makes sense. But this isn't documented anywhere I could find, so it took a while to find the root cause.