This is probably a feature request. Looking at `[p...
# general
This is probably a feature request. Looking at
and `[python-infer].assets`: These flags work one way, but I would like to invert the signals given to the python dep inference system. So, the flag enables checking all springs for possible imports or assets, and then you use code comments or a
(negative) dependency to exclude false positives. My code base has a lot of strings that look similar to an import but they aren't. So, turning string import inference on globally sounds very problematic to me. So, instead of excluding false positives, could I use comments to say
# pants: string_imports on
# pants: string_imports off
? In other words, I want to enable string import inference selectively with code comments. I think something similar would be great for assets too.
Anything is possible in a plugin. I take caution on tacking too much to the core dep inference.
FWIW have you actually tested how many strings ACTUALLY also match something importable AND it's incorrect? We have a large codebase and I can't think of 1 false positive
Well, I finally tested
with the help of
grep -Ir '"[a-z_]\+\(\.[a-z_]*\)\+"'
and the
goal in 2.16.0a0. I found only 1 false positive, so I added the
pants: no-infer-deps
comment on that and several other similar strings. I'm surprised there aren't a lot more. I also expected it to complain about a lot of strings that don't map to an actual module, but it works much better than that and ignores those strings. So, I was worried for nothing. I'll have to play with
next. Thanks @bitter-ability-32190 for making that string inference stuff work so smoothly!