Skip to content

Conversation

@KristofferC
Copy link
Member

There are more imports we can move to using : but this cleans up quite a bit for now. Also adds some CI to catch future things.

@KristofferC KristofferC requested a review from a team as a code owner July 2, 2025 10:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR cleans up unused and overly broad imports flagged by ExplicitImports.jl by switching to targeted using/import statements, unqualifying function calls where appropriate, and adds a CI job to enforce future import hygiene.

  • Replace fully-qualified calls (e.g., LibGit2.close, Pkg.generate) with unqualified functions and tighten imports to bring only needed symbols into scope.
  • Refactor dozens of modules to use using Module: symbol or import Module: symbol rather than importing entire modules.
  • Add a new GitHub Actions job under .github/workflows/check.yml that runs ExplicitImports.jl checks on the codebase.

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/repl.jl Replaced LibGit2.close(...) with close(...).
test/pkg.jl Similar unqualification of LibGit2.close(...).
src/precompile.jl Converted Pkg.-prefixed calls to unqualified names and tightened imports.
src/fuzzysorting.jl Dropped FuzzySorting. prefixes on fuzzyscore and levenshtein.
src/Types.jl Switched to named using/import for external modules and removed unused imports.
src/Resolve/Resolve.jl Refined imports for Printf, Random, and UUIDs.
src/Registry/Registry.jl Tightened imports, changed default depots to Base.DEPOT_PATH, and unqualified close.
src/REPLMode/REPLMode.jl Scoped imports for Dates, Markdown, and UUIDs.
src/PlatformEngines.jl Scoped imports for SHA, Downloads, Tar, and p7zip_jll.
src/Pkg.jl Scoped Dates imports, updated depots1 default, and unqualified internal calls.
src/Operations.jl Cleaned up imports and unqualified calls to is_tracking_repo, close, etc.
src/MiniProgressBars.jl Scoped imports of @sprintf from Printf.
src/GitTools.jl Scoped SHA and Printf, switched ensure_clone to local clone.
src/Artifacts.jl Explicitly imported artifact API symbols and sha256.
src/Apps/Apps.jl Scoped TOML and UUIDs imports and removed unused Pkg.Types imports.
src/API.jl Scoped imports, replaced depots() with Base.DEPOT_PATH, and unqualified calls.
ext/REPLExt/precompile.jl Unqualified precompile calls and tightened import clauses.
ext/REPLExt/REPLExt.jl Scoped using/import for Markdown, Dates, and UUIDs.
.github/workflows/check.yml Added ExplicitImports.jl CI job to catch future unused or implicit imports.
Comments suppressed due to low confidence (4)

test/repl.jl:31

  • The call to close is now unqualified but LibGit2.close was removed. You should bring close into scope (e.g. using LibGit2: close) or revert to LibGit2.close to avoid an undefined function error.
        close((LibGit2.init(".")))

test/pkg.jl:617

  • Similar to the other test, close is unqualified but not imported. Add using LibGit2: close or qualify as LibGit2.close to ensure the function is available.
                close(LibGit2.clone(TEST_PKG.url, "Example.jl"))

src/Types.jl:18

  • You export SHA1 but removed its import. Add import Base: SHA1 so that the SHA1 type is defined and can be exported.
using SHA: SHA, sha1

src/Registry/Registry.jl:269

  • You replaced LibGit2.close(repo) with close(repo) but did not import close. Consider using LibGit2: close or qualifying as LibGit2.close.
                        close(repo)

use ExplicitImports.jl to remove implicit imports from `using` etc
@KristofferC KristofferC force-pushed the pkg-explicitimports branch from 3f183e6 to c08a176 Compare July 2, 2025 10:48
@KristofferC
Copy link
Member Author

ERROR: LoadError: ImplicitImportsException
Module `Pkg.Registry` is relying on the following implicit imports:
* `print` which is exported by Base

not sure what that means, I also don't get it locally...

@KristofferC
Copy link
Member Author

@ericphanson any idea w.r.t the comment above?

@ericphanson
Copy link
Contributor

it is supposed to skip flagging usages of names from Base/Core by default, looks like that isn't happening here for some reason. If it doesn't repro locally that adds credence to it being a bug that was fixed since the old version used in the CI script

@github-project-automation github-project-automation bot moved this to New in Pkg.jl Jul 2, 2025
@IanButterworth IanButterworth moved this from New to In review in Pkg.jl Jul 2, 2025
@IanButterworth
Copy link
Member

Looks good now

@KristofferC KristofferC merged commit c82210a into pkg-runic Jul 8, 2025
3 checks passed
@KristofferC KristofferC deleted the pkg-explicitimports branch July 8, 2025 11:19
@github-project-automation github-project-automation bot moved this from In review to Done in Pkg.jl Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants