-
Notifications
You must be signed in to change notification settings - Fork 30
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
Dont dump none entity #31
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
39a1d56
Add .env folder to gitignore
zhiburt 9ff9816
Dont serialize map entity whereas valus is None
zhiburt fc35a3c
Add tests for None value in maps
zhiburt da4497c
Add more tests for None value in the map
zhiburt 0462456
Fix lint warnings
zhiburt 67ab23d
Ommit None values in sequences
zhiburt d7eb3ee
Add test for None in sequences
zhiburt 1d55b16
Add omitNone argument
zhiburt f81d051
Use omitNone flag
zhiburt 772abe4
Rename omitNone to omit_none
zhiburt 1732cd6
Address PR issues
zhiburt 2aebd0c
Update README.md
zhiburt e7b8ddd
Refactoring
zhiburt bf7d47c
Update README.md
zhiburt 8402fad
Update rtoml/__init__.py
zhiburt c1b8123
Refactoring lib.rs
zhiburt f37a0aa
Update README.md
zhiburt 0dfed85
Fix lint warnings
zhiburt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ __pycache__/ | |
.coverage | ||
.auto-format | ||
/toml-test/ | ||
/.env/ |
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
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
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 |
---|---|---|
|
@@ -61,3 +61,51 @@ def test_dump_file(tmp_path): | |
|
||
def test_varied_list(): | ||
assert rtoml.dumps({'test': [1, '2']}) == 'test = [1, "2"]\n' | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'input_obj,output_toml', | ||
[ | ||
({None: 1}, ''), | ||
({'key': None}, ''), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. |
||
({'foo': 'bar', 'key1': None}, 'foo = "bar"\n'), | ||
({'key1': None, 'foo': 'bar'}, 'foo = "bar"\n'), | ||
({'key1': None, 'foo': 'bar', 'key2': None}, 'foo = "bar"\n'), | ||
], | ||
) | ||
def test_none_map_value(input_obj, output_toml): | ||
assert rtoml.dumps(input_obj, include_none=False) == output_toml | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'input_obj,output_toml', | ||
[ | ||
([None], '[]'), | ||
(['a', None], '["a"]'), | ||
([None, 'b'], '["b"]'), | ||
(['a', None, 'b'], '["a", "b"]'), | ||
({'foo': 'bar', 'list': [None]}, 'foo = "bar"\nlist = []\n'), | ||
({'foo': 'bar', 'list': [None, 'b']}, 'foo = "bar"\nlist = ["b"]\n'), | ||
({'foo': 'bar', 'list': ['a', None]}, 'foo = "bar"\nlist = ["a"]\n'), | ||
({'foo': 'bar', 'list': ['a', None, 'b']}, 'foo = "bar"\nlist = ["a", "b"]\n'), | ||
], | ||
) | ||
def test_none_values_inside_list(input_obj, output_toml): | ||
assert rtoml.dumps(input_obj, include_none=False) == output_toml | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'input_obj,output_toml', | ||
[ | ||
((None), '"null"'), | ||
(('a', None), '["a"]'), | ||
((None, 'b'), '["b"]'), | ||
(('a', None, 'b'), '["a", "b"]'), | ||
({'foo': 'bar', 'list': (None)}, 'foo = "bar"\n'), | ||
({'foo': 'bar', 'list': (None, 'b')}, 'foo = "bar"\nlist = ["b"]\n'), | ||
({'foo': 'bar', 'list': ('a', None)}, 'foo = "bar"\nlist = ["a"]\n'), | ||
({'foo': 'bar', 'list': ('a', None, 'b')}, 'foo = "bar"\nlist = ["a", "b"]\n'), | ||
], | ||
) | ||
def test_none_values_inside_tuple(input_obj, output_toml): | ||
assert rtoml.dumps(input_obj, include_none=False) == output_toml |
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
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.
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 suspect we can do this in a more effecient way, e.g. only check instead the
$key.is_none()
logic etc.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.
Do you mean only check
$key.is_none()
?Because it would break the tests.