Dumb question. Reading the docs I couldn’t find a ...
# general
b
Dumb question. Reading the docs I couldn’t find a way to reference a dependency that is installed by another dependency. For example I have fastapi that references pydantic. If I import something from pydantic, pants will warn that the dependency couldn’t be inferred. How can I point it correctly without adding to the pyproject file? I’m using poetry_requirements
f
If you are importing a dependency in first-party code, then it is now a direct dependency of that first-party code and should be referenced in your pyproject file. The fact that it is also a transitive dependency of
fastapi
is beside the point.
In my view, this is just good "dependency hygiene."
b
Yes but this can also lead to incompatibilities
Like my previous post. Pants hanged because dependencies were incompatible
f
And making sure the version in pyproject matches the one chosen by
fastapi
doesn't fix the issue?
b
From the developer perspective i would prefer to let fastapi rule this. This would avoid confusions and save a big CI bill with hanging builds
Package update PRs come from renovate. So it’s not coming from developers
b
Modern resolvers shouldn't have an issue with that, but if you want you can slap a
# pants: no-infer-dep
on the import line
h
Are you not generating lock files?
And totally agree about specifying it as a direct dependency. If you rely on fastapi to vendor the package, you have no idea if your usage is valid with the package version they select. The only way to do that is to pin a range you know your usage is valid for. Then you guarantee compatibility with there’s by generating lock files.