Skip to content

Commit

Permalink
Add ExplicitImports
Browse files Browse the repository at this point in the history
ExplicitImports helps keeping functions well qualified and unambiguous
  • Loading branch information
Sbozzolo committed Jul 25, 2024
1 parent 5c9c98c commit d339424
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions .buildkite/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ClimaDiagnostics = "1ecacbb8-0713-4841-9a07-eb5aa8a2d53f"
ClimaTimeSteppers = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
Expand Down
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ClimaCore = "0.13.4, 0.14"
ClimaTimeSteppers = "0.7.10"
Dates = "1"
Documenter = "1"
ExplicitImports = "1.6"
JuliaFormatter = "1"
NCDatasets = "0.13.1, 0.14"
Profile = "1"
Expand All @@ -34,11 +35,12 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
ClimaTimeSteppers = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
ProfileCanvas = "efd6af41-a80b-495e-886c-e51b0c7d77a3"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "BenchmarkTools", "ClimaTimeSteppers", "Documenter", "JuliaFormatter", "Profile", "ProfileCanvas", "SafeTestsets", "Test"]
test = ["Aqua", "BenchmarkTools", "ClimaTimeSteppers", "Documenter", "ExplicitImports", "JuliaFormatter", "Profile", "ProfileCanvas", "SafeTestsets", "Test"]
34 changes: 34 additions & 0 deletions test/aqua.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Test
using ClimaDiagnostics
using Aqua
import ExplicitImports

@testset "Aqua tests" begin
Aqua.test_undefined_exports(ClimaDiagnostics)
Expand All @@ -9,3 +10,36 @@ using Aqua
Aqua.detect_ambiguities(ClimaDiagnostics; recursive = true)
Aqua.test_piracies(ClimaDiagnostics)
end

@testset "Explicit Imports" begin
@test isnothing(ExplicitImports.check_no_implicit_imports(ClimaDiagnostics))

# We import some variables to bring them to the top level, so that they are
# easier to use in user packages. These are technically stale imports, so we
# have to ignore them

ignore = (
:DiagnosticVariable,
:DivisorSchedule,
:ScheduledDiagnostic,
:average_pre_output_hook!,
)
@test isnothing(
ExplicitImports.check_no_stale_explicit_imports(
ClimaDiagnostics;
ignore,
),
)

# ClimaCore idiosyncrasies
ignore = (:HDF5, :topology, :vertical_topology)
@test isnothing(
ExplicitImports.check_all_qualified_accesses_via_owners(
ClimaDiagnostics;
ignore,
),
)
@test isnothing(
ExplicitImports.check_no_self_qualified_accesses(ClimaDiagnostics),
)
end

0 comments on commit d339424

Please sign in to comment.