purple-umbrella-89891
11/29/2022, 4:23 PMwith suppress(...): import x
) in our codebase that are local/internal packages, which are not available in any repository. During pants test, we get warnings in the form Pants cannot infer owners for the following imports in the target a/b/c.py: x
. We have disabled the warnings using # pants: no-infer-dep
in the code but would like to do it centrally and are trying the !{bad_address}
syntax as shown here. However, since x
is not in the known dependencies, it does not work. Any ideas how to make it work globally instead of annotating every import?bitter-ability-32190
11/29/2022, 4:24 PMtry/except ImportError
blockcontextlib.suppress
as well (although that is tricker from an AST perspective)curved-television-6568
11/29/2022, 4:42 PMbitter-ability-32190
11/29/2022, 4:43 PMimport contextlib
vs from contextlib import suppress
curved-television-6568
11/29/2022, 4:44 PMbitter-ability-32190
11/29/2022, 4:46 PMpurple-umbrella-89891
11/30/2022, 10:31 AMwith suppress()
to try/except
since that is caught and maybe try to create a PR in pants for adding suppress
support.bitter-ability-32190
11/30/2022, 12:29 PMpurple-umbrella-89891
11/30/2022, 2:12 PMsuppress
, I'm just trying to gain experience and maybe cover some other corner cases. What would be the recommended way to do it?
Somehow overriding this rule would do the job, but I didn't find a way to do it. Defining my own equivalent rule did not work (it's ambiguous for the rule engine) and using a union as described in the documentation for custom python_artifact kwargs is not possible, because the current rule is not declared as @union
. Would I have to start from some higher level classes like InferDependenciesRequest
or PythonInferSubsystem
and wrap or derive from every class inbetween to do this?bitter-ability-32190
11/30/2022, 6:35 PM