-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move ConstructionBase dependency to an extension on 1.9+ (#112)
* Move ConstructionBase dependency to an extension on 1.9+ The dependency on ConstructionBase serves to provide a few convenience methods for users of packages like Accessors; it doesn't provide any functionality used directly by Legolas. This makes it a perfect candidate for a package extension. Package extensions are new in Julia 1.9, and Legolas currently supports Julia 1.6. That means that we can't fully remove ConstructionBase as a direct dependency yet, but we can restructure things to make that as easy as possible once we drop support for earlier Julia versions. * Bump Aqua compatibility to 0.8 to fix Julia 1.6 test failure Requires adding stdlib entries to `[compat]` * Bump version
- Loading branch information
Showing
4 changed files
with
49 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module LegolasConstructionBaseExt | ||
|
||
using ConstructionBase | ||
using Legolas | ||
|
||
using Legolas: AbstractRecord | ||
|
||
# We need a bit of extra work to integrate with ConstructionBase for pre-1.7 due | ||
# to the overload of `propertynames(::Tables.AbstractRow)`. We could overload | ||
# `check_properties_are_fields` but that's not part of the public API, so this | ||
# is safer. | ||
if VERSION < v"1.7" | ||
ConstructionBase.getproperties(r::AbstractRecord) = NamedTuple(r) | ||
|
||
# This is largely copy-paste from `ConstructionBase.setproperties_object`: | ||
# https://github.com/JuliaObjects/ConstructionBase.jl/blob/cd24e541fd90ab54d2ee12ddd6ccd229be9a5f1e/src/ConstructionBase.jl#L211-L218 | ||
function ConstructionBase.setproperties(r::R, patch::NamedTuple) where {R<:AbstractRecord} | ||
nt = getproperties(r) | ||
nt_new = merge(nt, patch) | ||
ConstructionBase.check_patch_properties_exist(nt_new, nt, r, patch) | ||
args = Tuple(nt_new) # old Julia inference prefers if we wrap in `Tuple` | ||
return constructorof(R)(args...) | ||
end | ||
end | ||
|
||
function ConstructionBase.constructorof(::Type{R}) where {R<:AbstractRecord} | ||
nt = NamedTuple{fieldnames(R)} | ||
T = Base.typename(R).wrapper | ||
return (args...) -> T(nt(args)) | ||
end | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
770e615
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
770e615
There was a problem hiding this comment.
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/107457
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.
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: