ExplicitImports.jl icon indicating copy to clipboard operation
ExplicitImports.jl copied to clipboard

Check all imports are via `using` (not `import`)

Open nickrobinson251 opened this issue 3 months ago • 1 comments

Would very much like this feature -- does it seem possible and a fit for this package?

i.e. convert

import Foo
import Bar: baz

to

using Foo: Foo
using Bar: Bar, baz

Users may need to change their code (if they previously extended baz like baz() = ... to do so like Bar.baz() = ...) so we'd have to tell them to do that in the text output i guess

(Perhaps we could even identify if any methods were extended this way? And list them? And choose between using Bar: Bar, baz and using Bar: baz appropriately?)

nickrobinson251 avatar Aug 07 '25 10:08 nickrobinson251

JuliaFormatter can do the toplevel conversion, but I don’t think it makes method definitions use the qualified name: https://domluna.github.io/JuliaFormatter.jl/dev/#import_to_using

We could probably do both but it would be a bit of a lift to be fully semantic rather than find and replace. Definitely lower priority than #114

ericphanson avatar Aug 07 '25 12:08 ericphanson