Generate version-agnostic Protocols for any SPDX 3.x#52
Draft
bact wants to merge 3 commits into
Draft
Conversation
(This built on top of the bact:add-spdx-3-1 branch that adds SPDX 3.1 model loading) Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR requires
SHACLObjectSetProtocol(Protocol), etc from JPEWdev/shacl2code#114 (shacl2code>1.1.0). It will failed the test until we got the Protocol support from the bindings thatshacl2codegenerated (using new--include-protocolsoption).This PR contains changes from #46 (Add SPDX 3.1), because we need SPDX 3.1 binding to test Protocols. Consider merging #46 before this one.
What this PR trying to do
Each minor version has its own generated types, so
v3_0_1.Elementandv3_1.Elementare technically distinct. Theprotocolssubmodule exposesversion-neutral protocol types so one function works with any 3.x version:
Class hierarchy is preserved (
protocols.AgentacceptsPerson,Tool, etc.from any version). These protocols are for static typing only; construct objects
with a concrete version (
v3_0_1.Person()ormodel.Person()fromload()).How it gets done
The
gen/generate-protocolsscript combinesspdx_python_model.bindings.protocolsfrom each generated version of SPDX 3 model (fromshacl2code) into to a single version-agnosticspdx_python_model.protocolsthat can be used across all version of SPDX 3 (provided that SPDX 3 keeps backward compatibility across minor versions).Merge rules: