-
Notifications
You must be signed in to change notification settings - Fork 47
[Internal, New Feature, No Breaking] Rewrite constructor part 1 #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Paalon
wants to merge
16
commits into
JuliaData:master
Choose a base branch
from
Paalon:schema-constructor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Define constructors for each schema. However, it is not completed. So this is the part 1. Because the two tags: `!!merge` and `!!value` remain in the construction of mapping. I added a bit modification in the constructor of `ConstructorError` to increase the readability. And also I added some TODO comments and my thoughts.
Member
|
Is this still live? |
|
|
||
| Constructor(::Nothing) = Constructor(Dict{String,Function}()) | ||
| SafeConstructor(constructors::Dict = Dict(), multi_constructors::Dict = Dict()) = Constructor(merge(copy(default_yaml_constructors), constructors), multi_constructors) | ||
| # Paalon: I don't know what is safe. |
Contributor
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.
I believe unsafe refers to things like this that you can do in pyyaml:
$ python
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.load("""!!python/object/apply:subprocess.Popen\n- [echo, hello]\n""", Loader=yaml.Loader)
<Popen: returncode: None args: ['echo', 'hello']>
>>> hello
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.
Abstract
Detail
Rewrite construct functions in
src/constructor.jl. Add constructor functions for the three essential YAML schemata. However this is not completed because processing for tag!!mergeand!!valueare still tightly connected toconstruct_mappingetc.ConstructorError.flatten_mappingto always returnnothing.src/constructor.jltosrc/constructor_yaml_jl_0_4_10.jlfor the YAML.jl 0.4.10 schema:construct_yaml_null→construct_yaml_jl_0_4_10_schema_nullbool_values→yaml_jl_0_4_10_schema_bool_valuesconstruct_yaml_bool→construct_yaml_jl_0_4_10_schema_boolconstruct_yaml_int→construct_yaml_jl_0_4_10_schema_intconstruct_yaml_float→construct_yaml_jl_0_4_10_schema_floattimestamp_pat→yaml_jl_0_4_10_schema_timestamp_regexconstruct_yaml_timestamp→construct_yaml_jl_0_4_10_schema_timestampconstruct_yaml_omap→construct_yaml_jl_0_4_10_schema_timestampconstruct_yaml_pairs→construct_yaml_jl_0_4_10_schema_timestampconstruct_yaml_set→construct_yaml_jl_0_4_10_schema_setconstruct_yaml_str→construct_yaml_jl_0_4_10_schema_strconstruct_yaml_seq→construct_yaml_jl_0_4_10_schema_seqconstruct_yaml_map→construct_yaml_jl_0_4_10_schema_mapconstruct_yaml_object→construct_yaml_jl_0_4_10_schema_objectconstruct_yaml_binary→construct_yaml_jl_0_4_10_schema_binaryconstruct_undefined→construct_undefined_yaml_jl_0_4_10_schema: this requires test's modification.default_yaml_constructors→yaml_jl_0_4_10_schema_constructors: this requires test's modification.src/constructor_failsafe.jl,src/constructor_json.jlandsrc/constructor_core.jl.This PR does not change any commonly used API (
load,load_all,write, etc.).