Skip to content

Commit

Permalink
support code-generated exports in staleness check (#72)
Browse files Browse the repository at this point in the history
* add test

* fix

* bump version
  • Loading branch information
ericphanson authored Jul 2, 2024
1 parent eda7501 commit 900a49f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ExplicitImports"
uuid = "7d51a73a-1435-4ff3-83d9-f097790105c7"
authors = ["Eric P. Hanson"]
version = "1.7.0"
version = "1.8.0"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand All @@ -19,6 +19,7 @@ LinearAlgebra = "<0.0.1, 1"
Logging = "<0.0.1, 1"
Markdown = "<0.0.1, 1"
Pkg = "<0.0.1, 1"
Reexport = "1.2.2"
TOML = "<0.0.1, 1"
Test = "<0.0.1, 1"
UUIDs = "<0.0.1, 1"
Expand All @@ -31,8 +32,9 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[targets]
test = ["Aqua", "DataFrames", "LinearAlgebra", "Logging", "Markdown", "Pkg", "UUIDs", "Test"]
test = ["Aqua", "DataFrames", "LinearAlgebra", "Logging", "Markdown", "Pkg", "UUIDs", "Reexport", "Test"]
5 changes: 5 additions & 0 deletions src/improper_explicit_imports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ function analyze_explicitly_imported_names(mod::Module, file=pathof(mod);
output.importing_from)
internal_import = Base.moduleroot(mod) == Base.moduleroot(output.importing_from)
stale = (; row.name, row.module_path) in stale_imports
# Cannot be stale if public or exported in the module `mod`
# https://github.com/ericphanson/ExplicitImports.jl/issues/69
if public_or_exported(mod, row.name)
stale = false
end
push!(table,
(; output..., importing_from_owns_name, importing_from_submodule_owns_name,
stale, internal_import))
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,15 @@ end
@test owner_mod_for_printing(Core, :println, Core.println) == Core
end

# https://github.com/ericphanson/ExplicitImports.jl/issues/69
@testset "Reexport support" begin
@test check_no_stale_explicit_imports(TestMod15, "test_mods.jl") === nothing
@test isempty(improper_explicit_imports_nonrecursive(TestMod15, "test_mods.jl"))
@test isempty(improper_explicit_imports(TestMod15, "test_mods.jl")[1][2])
end

if VERSION >= v"1.7-"
# https://github.com/ericphanson/ExplicitImports.jl/issues/70
@testset "Compat skipping" begin
@test check_all_explicit_imports_via_owners(TestMod14, "test_mods.jl") === nothing
@test check_all_qualified_accesses_via_owners(TestMod14, "test_mods.jl") === nothing
Expand Down
8 changes: 8 additions & 0 deletions test/test_mods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,11 @@ if VERSION >= v"1.7-"

end # TestMod14
end

# https://github.com/ericphanson/ExplicitImports.jl/issues/69
module TestMod15
using Reexport

@reexport using ..Exporter: exported_a

end # TestMod15

2 comments on commit 900a49f

@ericphanson
Copy link
Owner Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/110297

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.8.0 -m "<description of version>" 900a49f016548093362760728988d379f26b35b6
git push origin v1.8.0

Please sign in to comment.