ericphanson / ExplicitImports.jl

Developer tooling for Julia namespace management: detecting implicit imports, improper explicit imports, and improper qualified accesses
https://ericphanson.github.io/ExplicitImports.jl/
MIT License
77 stars 4 forks source link

ExplicitExports always suggests exporting from the "defining" module #24

Closed ericphanson closed 6 months ago

ericphanson commented 6 months ago

because:

julia> module M
       using StaticArrays
       end
Main.M

julia> Base.which(M, :StaticVector)
StaticArraysCore

so if you use StaticVector, we suggest using StaticArraysCore: StaticVector rather than using StaticArrays: StaticVector.

In some cases folks would prefer to get the outermost suggestion, xref https://github.com/JuliaStats/MixedModels.jl/pull/748#discussion_r1510350562.

ericphanson commented 6 months ago

Not 100% sure what the best semantics here. Definitely seems suboptimal to require folks to add new deps...

I guess what we want is all the suggestions to come from the modules that have implicit imports, so we are just switching implicit to explicit. I think we should have a name => [exporting_modules] dict (which find_implicit_imports could return), and then instead of resolving names via which directly, we could check which of the modules that provides a given name resolves to the same binding as the one in the actual module does, and then print that exporting module rather than the "source module".