From 651a690ff27f1d7127d1aa4e2936394bfa823010 Mon Sep 17 00:00:00 2001 From: Claude Code Date: Fri, 2 Jan 2026 04:41:51 -0500 Subject: [PATCH] Improve explicit imports hygiene MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace `using Package` with selective `using Package: name1, name2` imports to eliminate all implicit imports - Add ExplicitImports.jl tests to CI to ensure import hygiene is maintained - Updated imports in: - src/ModelOrderReduction.jl: Added explicit imports for DocStringExtensions, ModelingToolkit, LinearAlgebra, and Setfield - src/utils.jl: Added explicit import for SparseArrays.sparse - src/precompile.jl: Added explicit imports for PrecompileTools macros - Added test/explicit_imports.jl with tests for no implicit or stale imports - Added ExplicitImports to test dependencies in test/Project.toml All tests pass. The package now follows best practices for explicit imports, reducing the risk of breakage from transitive dependency changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- src/ModelOrderReduction.jl | 10 ++++++---- src/precompile.jl | 2 +- src/utils.jl | 2 +- test/Project.toml | 6 ++++-- test/explicit_imports.jl | 13 +++++++++++++ test/runtests.jl | 3 +++ 6 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 test/explicit_imports.jl diff --git a/src/ModelOrderReduction.jl b/src/ModelOrderReduction.jl index 05be57d..6eb4d37 100644 --- a/src/ModelOrderReduction.jl +++ b/src/ModelOrderReduction.jl @@ -1,11 +1,13 @@ module ModelOrderReduction -using DocStringExtensions +using DocStringExtensions: DocStringExtensions, FUNCTIONNAME, SIGNATURES, TYPEDSIGNATURES -using ModelingToolkit -using LinearAlgebra +using ModelingToolkit: ModelingToolkit, @variables, Differential, Equation, Num, ODESystem, + SymbolicUtils, Symbolics, arguments, build_function, complete, + expand, substitute, tearing_substitution +using LinearAlgebra: LinearAlgebra, /, \, mul!, qr, svd -using Setfield +using Setfield: Setfield, @set! include("utils.jl") diff --git a/src/precompile.jl b/src/precompile.jl index 6777c0c..a352b78 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -1,4 +1,4 @@ -using PrecompileTools +using PrecompileTools: PrecompileTools, @compile_workload, @setup_workload @setup_workload begin # Setup code - create minimal test data diff --git a/src/utils.jl b/src/utils.jl index fddcff8..bb66e38 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -1,4 +1,4 @@ -using SparseArrays +using SparseArrays: SparseArrays, sparse using ModelingToolkit: iscall, operation """ diff --git a/test/Project.toml b/test/Project.toml index 3c0e073..027be15 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,14 +1,16 @@ [deps] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" -OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" MethodOfLines = "94925ecb-adb7-4558-8ed8-f975c56a0bf4" ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" +OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] Aqua = "0.8" -OrdinaryDiffEq = "6" +ExplicitImports = "1" MethodOfLines = "0.11" ModelingToolkit = "10.10" +OrdinaryDiffEq = "6" SafeTestsets = "0.1" diff --git a/test/explicit_imports.jl b/test/explicit_imports.jl new file mode 100644 index 0000000..ae890d0 --- /dev/null +++ b/test/explicit_imports.jl @@ -0,0 +1,13 @@ +using Test +using ExplicitImports +using ModelOrderReduction + +@testset "ExplicitImports" begin + @testset "No implicit imports" begin + @test check_no_implicit_imports(ModelOrderReduction) === nothing + end + + @testset "No stale explicit imports" begin + @test check_no_stale_explicit_imports(ModelOrderReduction) === nothing + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 4953946..6d1c1af 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,6 +3,9 @@ using SafeTestsets @safetestset "Quality Assurance" begin include("qa.jl") end +@safetestset "Explicit Imports" begin + include("explicit_imports.jl") +end @safetestset "POD" begin include("DataReduction.jl") end