Skip to content

Conversation

@github-actions
Copy link
Contributor

This pull request changes the compat entry for the Bijections package from 0.1.4 to 0.1.4, 0.2.
This keeps the compat entries for earlier versions.

Note: I have not tested your package with this new compat entry.
It is your responsibility to make sure that your package tests pass before you merge this pull request.

@zeptodoctor zeptodoctor force-pushed the compathelper/new_version/2025-05-27-01-03-41-173-03275239096 branch from 84fd707 to 009ccc6 Compare May 27, 2025 01:03
@goerz
Copy link
Member

goerz commented May 27, 2025

@goerz
Copy link
Member

goerz commented May 27, 2025

In JuliaCollections/Bijections.jl#15 (comment), @mofeing wrote:

The only thing you should update is when you have a field that is a Bijection. So, for example, you must change it here:

anchor_keys::Bijections.Bijection{String,String}

from

anchor_keys::Bijections.Bijection{String,String}

to

anchor_keys::Bijections.Bijection{String,String,Dict{String,String},Dict{String,String}}

It seems like I don't even have to do that!

pkg> add Bijections
   Resolving package versions...
    Updating `/private/var/folders/mm/rr6dgkzj0l5_j_ntxcg_hlth0000gn/T/jl_ijf7Kj/Project.toml`
  [e2ed5e7c] + Bijections v0.2.1

julia> using Bijections

julia> struct MyStruct
       d::Bijections.Bijection{String,String}
       end

julia> MyStruct(Bijection{String,String}())
MyStruct(Bijection{String, String, Dict{String, String}, Dict{String, String}}())

And, DocumenterCitations seems to run through fine without any modifications. I don't understand why that works, though. Type definitions in Julia can still sometimes be mysterious.

@goerz goerz merged commit 4a3425c into master May 27, 2025
8 checks passed
@goerz goerz deleted the compathelper/new_version/2025-05-27-01-03-41-173-03275239096 branch May 27, 2025 11:04
@mofeing
Copy link

mofeing commented May 27, 2025

It seems like I don't even have to do that!

pkg> add Bijections
   Resolving package versions...
    Updating `/private/var/folders/mm/rr6dgkzj0l5_j_ntxcg_hlth0000gn/T/jl_ijf7Kj/Project.toml`
  [e2ed5e7c] + Bijections v0.2.1

julia> using Bijections

julia> struct MyStruct
       d::Bijections.Bijection{String,String}
       end

julia> MyStruct(Bijection{String,String}())
MyStruct(Bijection{String, String, Dict{String, String}, Dict{String, String}}())

And, DocumenterCitations seems to run through fine without any modifications. I don't understand why that works, though. Type definitions in Julia can still sometimes be mysterious.

Be careful. The field is still non-concrete:

julia> fieldtypes(MyStruct)
(Bijection{String, String},)

julia> fieldtypes(MyStruct) .|> isconcretetype
(false,)

The reason why you see it as the full type is because calling typeof on the d field is being performed dynamically, and because you're performing the gefield on a global scope (the REPL), it seems like these dynamic calls to type are considered ok.

Check out what happens when we analyze a function that accesses the d field:

julia> f(d) = d.d
f (generic function with 1 method)

julia> @code_typed f(x)
CodeInfo(
1%1 = Base.getfield(d, :d)::Bijection{String, String}
└──      return %1
) => Bijection{String, String}

The result is not concrete.

but if we specify the full type in the struct...

julia> struct MyStruct2
               d::Bijections.Bijection{String,String,Dict{String,String},Dict{String,String}}
               end

julia> y = MyStruct2(Bijection{String,String}())
MyStruct2(Bijection{String, String, Dict{String, String}, Dict{String, String}}())

julia> @code_typed f(y)
CodeInfo(
1%1 = Base.getfield(d, :d)::Bijection{String, String, Dict{String, String}, Dict{String, String}}
└──      return %1
) => Bijection{String, String, Dict{String, String}, Dict{String, String}}

Now it is.

All behavior should be mostly the same, so it'll work for your case. But the type-inference will be affected.

@goerz
Copy link
Member

goerz commented May 27, 2025

Right, yeah… I did figure I was moving from a concrete to non-concrete field, but I'm still surprised that the syntax works. I was actually ready to change that to just Bijections.Bijection, but then it turned out it ran through without that change. I didn't know you could specify only some of the type parameters.

I'm fine with having a non-concrete field. There's already the style field that's Any, and a Documenter plugin is basically a Singleton anyway that is not performance critical. That annotations are more for protecting against unexpected types that would indicate that something is being called incorrectly.

The main concern is really with being compatible with as many releases of any dependency as possible. Documenter and plugins like DocumenterCitations are potentially dependencies for building the documentation of all Julia packages, so if I had to restrict to Bijections >= 0.2 then any package that was still depending on (or had any of its dependencies depend on) Bijections < 0.2 would run into a dependency conflict and fail to build its documentation. So I have to by hyper-conservative with any dependencies that I add to DocumenterCitations – I was even considering just vendoring the small subset of Bijections I was actually using. But for now, it seems to be okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants