Skip to content

Commit

Permalink
don't skip source modules (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericphanson authored May 25, 2024
1 parent d46bc8e commit ff24993
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
8 changes: 5 additions & 3 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.4.4"
version = "1.4.5"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand All @@ -16,9 +16,10 @@ JuliaSyntax = "0.4.8"
LinearAlgebra = "<0.0.1, 1"
Logging = "<0.0.1, 1"
Markdown = "<0.0.1, 1"
Pkg = "<0.0.1, 1"
UUIDs = "<0.0.1, 1"
TOML = "<0.0.1, 1"
Test = "<0.0.1, 1"
Pkg = "<0.0.1, 1"
julia = "1.7"

[extras]
Expand All @@ -28,7 +29,8 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "DataFrames", "LinearAlgebra", "Logging", "Markdown", "Pkg", "Test"]
test = ["Aqua", "DataFrames", "LinearAlgebra", "Logging", "Markdown", "Pkg", "UUIDs", "Test"]
1 change: 0 additions & 1 deletion src/ExplicitImports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ function explicit_imports_nonrecursive(mod::Module, file=pathof(mod);
needed_names = Set(nt.name for nt in needs_explicit_import)
filter!(all_implicit_imports) do (k, v)
k in needed_names || return false
should_skip(v.source; skip) && return false
any(mod -> should_skip(mod; skip), v.exporters) && return false
return true
end
Expand Down
7 changes: 7 additions & 0 deletions test/examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,10 @@ using ..Exporter2

exported_a
end

# https://github.com/ericphanson/ExplicitImports.jl/issues/29
module Mod29
using UUIDs

v = UUID[]
end
13 changes: 12 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using ExplicitImports: analyze_all_names, has_ancestor, should_skip,
using Test
using DataFrames
using Aqua
using Logging
using Logging, UUIDs
using AbstractTrees
using ExplicitImports: is_function_definition_arg, SyntaxNodeWrapper, get_val
using ExplicitImports: is_struct_type_param, is_struct_field_name, is_for_arg,
Expand Down Expand Up @@ -200,6 +200,17 @@ end
@test contains(str, "- qr")
end

@testset "Don't skip source modules (#29)" begin
# In this case `UUID` is defined in Base but exported in UUIDs
ret = ExplicitImports.find_implicit_imports(Mod29)[:UUID]
@test ret.source == Base
@test ret.exporters == [UUIDs]
# We should NOT skip it, even though `skip` includes `Base`, since the exporters
# are not skipped.
statements = using_statement.(explicit_imports_nonrecursive(Mod29, "examples.jl"))
@test statements == ["using UUIDs: UUIDs", "using UUIDs: UUID"]
end

@testset "Exported module (#24)" begin
statements = using_statement.(explicit_imports_nonrecursive(Mod24, "examples.jl"))
# The key thing here is we do not have `using .Exporter: exported_a`,
Expand Down

2 comments on commit ff24993

@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/107638

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.4.5 -m "<description of version>" ff24993ae596e3471845ed43f90f8b320e3b2bc3
git push origin v1.4.5

Please sign in to comment.