high-yak-85899
11/05/2022, 9:24 PM# pants: no-infer-dep
directive. Is there something like # pants: allow-missing-dep
?happy-kitchen-89482
11/05/2022, 10:43 PMbitter-ability-32190
11/05/2022, 11:19 PMcareful-address-89803
11/06/2022, 2:45 AMhigh-yak-85899
11/07/2022, 5:31 PMhappy-kitchen-89482
11/07/2022, 5:32 PMbitter-ability-32190
11/07/2022, 5:32 PMYeah, exactly like that. In a couple places, we have some try/except style imports that I'd like pants to try to infer if it can but be satisfied and carry on with the program if it can't.How does today's support not suffice?
high-yak-85899
11/07/2022, 5:32 PMbitter-ability-32190
11/07/2022, 5:34 PMhigh-yak-85899
11/07/2022, 5:35 PMbitter-ability-32190
11/07/2022, 5:35 PMhigh-yak-85899
11/07/2022, 6:01 PMa.py
, b.py
, and c.py
. The relationship is such that a.py
depends on b.py
which depends on c.py
. In a.py
, I have a statement like
try:
import b
except (ImportError, ModuleNotFoundError):
# Totally okay to happen
pass
b.py
has a statement like
import c
and I was expecting pants to transitively carry through the try/except
allowance. c.py
missing is actually the thing that causes b.py
import to fail. Is our only recourse here to similarly wrap import c
in try/except
?bitter-ability-32190
11/07/2022, 6:06 PMhigh-yak-85899
11/07/2022, 6:07 PMtry:
import c
except ModuleNotFoundError as e:
raise e
so that it propagates up for the handling we actually wantedbitter-ability-32190
11/07/2022, 6:07 PMImportError
is the key, let me checkImportError
: https://github.com/pantsbuild/pants/blob/7de8661340fce65ba0e4f863c2e29f1e99b98363/[…]ackend/python/dependency_inference/scripts/dependency_parser_pyhigh-yak-85899
11/07/2022, 6:28 PMModuleNotFoundError
?bitter-ability-32190
11/07/2022, 6:29 PMImportError
ImportError
?happy-kitchen-89482
11/07/2022, 6:41 PMimport c
is in some sense more “correct” in terms of modeling what’s going on?high-yak-85899
11/07/2022, 6:44 PM