Yeah, ExplicitImports can’t tell if you’ve loaded a package for the “side-effects” (e.g. new methods) vs to get new names in your namespace. It can only say “PkgX has provided such and such names into your namespace and you aren’t using them” (though it isn’t 100% accurate at this currently and I don’t think the check_
functions use this).
However, I think a good syntax here is: if you are only loading ForwardDiff for the “side-effects”, you could indicate this with
import ForwardDiff as _
i.e., I want to load ForwardDiff but I don’t want it to bring any names into my namespace, not even the module itself, since I’m not using them. I checked Julia 1.11 and this syntax does seem to be supported already!
I could imagine a future ExplicitImports version suggesting rewrites of import ForwardDiff
into import ForwardDiff as _
if there are no names being used (thereby assuming it is there for the side-effects). Then the dev can delete it if they know they aren’t in fact using the side-effects.