Skip to content

Commit

Permalink
Import ruamel.yaml 0.17.31 source.
Browse files Browse the repository at this point in the history
  • Loading branch information
gizmoguy committed Jun 8, 2023
1 parent 8041717 commit bbb1df9
Show file tree
Hide file tree
Showing 26 changed files with 882 additions and 205 deletions.
5 changes: 5 additions & 0 deletions .hgtags
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,8 @@ c887dfe19e2f01b770a2b4b04163a01e00a33f85 0.17.21
b4c00a90b4d003ff3f239df622fb638cd33146dd 0.17.23
4309006902d2453399588f4ddccfb3fc460e1eba 0.17.24
12a642699fa84085248317ee765c4956f6deeec7 0.17.25
8a26dc2a156aa189c472b5efeb10e8c3de206091 0.17.26
f76dde33e9a175e7505a2933a5c2423d4e3db9aa 0.17.27
d522a02977979e5feef1d0f1b94b6b7f823c0bdd 0.17.28
41fd3925691106c999959771e54bd69cce70d1c8 0.17.29
0ed43732b9e309d397e9c9cfa74f115f40f51a6b 0.17.30
28 changes: 28 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
[0, 17, 31]: 2023-05-31
- added tag.setter on `ScalarEvent` and on `Node`, that takes either
a `Tag` instance, or a str
(reported by `Sorin Sbarnea <https://sourceforge.net/u/ssbarnea/profile/>`__)

[0, 17, 30]: 2023-05-30
- fix issue 467, caused by Tag instances not being hashable (reported by
`Douglas Raillard
<https://bitbucket.org/%7Bcf052d92-a278-4339-9aa8-de41923bb556%7D/>`__)

[0, 17, 29]: 2023-05-30
- changed the internals of the tag property from a string to a class which allows
for preservation of the original handle and suffix. This should
result in better results using documents with %TAG directives, as well
as preserving URI escapes in tag suffixes.

[0, 17, 28]: 2023-05-26
- fix for issue 464: documents ending with document end marker without final newline
fail to load (reported by `Mariusz Rusiniak <https://sourceforge.net/u/r2dan/profile/>`__)

[0, 17, 27]: 2023-05-25
- fix issue with inline mappings as value for merge keys
(reported by Sirish on `StackOverflow <https://stackoverflow.com/q/76331049/1307905>`__)
- fix for 468, error inserting after accessing merge attribute on ``CommentedMap``
(reported by `Bastien gerard <https://sourceforge.net/u/bagerard/>`__)
- fix for issue 461 pop + insert on same `CommentedMap` key throwing error
(reported by `John Thorvald Wodder II <https://sourceforge.net/u/jwodder/profile/>`__)

[0, 17, 26]: 2023-05-09
- Fix for error on edge cage for issue 459

Expand Down
36 changes: 32 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ ruamel.yaml

``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python.

:version: 0.17.26
:updated: 2023-05-09
:version: 0.17.31
:updated: 2023-05-31
:documentation: http://yaml.readthedocs.io
:repository: https://sourceforge.net/projects/ruamel-yaml/
:pypi: https://pypi.org/project/ruamel.yaml/
Expand Down Expand Up @@ -61,8 +61,36 @@ ChangeLog

.. should insert NEXT: at the beginning of line for next key (with empty line)
0.17.31 (2023-05-31):
- added tag.setter on `ScalarEvent` and on `Node`, that takes either
a `Tag` instance, or a str
(reported by `Sorin Sbarnea <https://sourceforge.net/u/ssbarnea/profile/>`__)

0.17.30 (2023-05-30):
- fix issue 467, caused by Tag instances not being hashable (reported by
`Douglas Raillard
<https://bitbucket.org/%7Bcf052d92-a278-4339-9aa8-de41923bb556%7D/>`__)

0.17.29 (2023-05-30):
- changed the internals of the tag property from a string to a class which allows
for preservation of the original handle and suffix. This should
result in better results using documents with %TAG directives, as well
as preserving URI escapes in tag suffixes.

0.17.28 (2023-05-26):
- fix for issue 464: documents ending with document end marker without final newline
fail to load (reported by `Mariusz Rusiniak <https://sourceforge.net/u/r2dan/profile/>`__)

0.17.27 (2023-05-25):
- fix issue with inline mappings as value for merge keys
(reported by Sirish on `StackOverflow <https://stackoverflow.com/q/76331049/1307905>`__)
- fix for 468, error inserting after accessing merge attribute on ``CommentedMap``
(reported by `Bastien gerard <https://sourceforge.net/u/bagerard/>`__)
- fix for issue 461 pop + insert on same `CommentedMap` key throwing error
(reported by `John Thorvald Wodder II <https://sourceforge.net/u/jwodder/profile/>`__)

0.17.26 (2023-05-09):
- Fix for error on edge cage for issue 459
- fix for error on edge cage for issue 459

0.17.25 (2023-05-09):
- fix for regression while dumping wrapped strings with too many backslashes removed
Expand Down Expand Up @@ -158,7 +186,7 @@ ChangeLog
attrs with `@attr.s()` (both reported by `ssph <https://sourceforge.net/u/sph/>`__)

0.17.11 (2021-08-19):
- fix error baseclass for ``DuplicateKeyErorr`` (reported by `Łukasz Rogalski
- fix error baseclass for ``DuplicateKeyError`` (reported by `Łukasz Rogalski
<https://sourceforge.net/u/lrogalski/>`__)
- fix typo in reader error message, causing `KeyError` during reader error
(reported by `MTU <https://sourceforge.net/u/mtu/>`__)
Expand Down
6 changes: 3 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

_package_data = dict(
full_package_name='ruamel.yaml',
version_info=(0, 17, 26),
__version__='0.17.26',
version_timestamp='2023-05-09 21:59:45',
version_info=(0, 17, 31),
__version__='0.17.31',
version_timestamp='2023-05-31 07:56:46',
author='Anthon van der Neut',
author_email='[email protected]',
description='ruamel.yaml is a YAML parser/emitter that supports roundtrip preservation of comments, seq/map flow style, and map key order', # NOQA
Expand Down
2 changes: 1 addition & 1 deletion _doc/_static/pypi.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions _test/test_api_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def test_read_unicode(self, tmpdir: Any) -> None:
with open(file_name, 'wb') as fp:
fp.write('text: HELLO_WORLD©\n'.encode('utf-8'))
text_dict = yaml.load(open(file_name, 'r'))
print(text_dict)
assert text_dict['text'] == 'HELLO_WORLD©'


Expand Down
2 changes: 1 addition & 1 deletion _test/test_cyaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest # type: ignore # NOQA
from textwrap import dedent

NO_CLIB_VER = (3, 10)
NO_CLIB_VER = (3, 12)


@pytest.mark.skipif( # type: ignore
Expand Down
30 changes: 30 additions & 0 deletions _test/test_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,36 @@ def test_multi_doc_ends_only(self) -> None:
docs = list(round_trip_load_all(inp, version=(1, 2)))
assert docs == [['a'], ['b']]

def test_single_scalar_comment(self) -> None:
from ruamel import yaml

inp = """\
one # comment
two
"""
with pytest.raises(yaml.parser.ParserError):
d = list(round_trip_load_all(inp, version=(1, 2))) # NOQA

def test_scalar_after_seq_document(self) -> None:
from ruamel import yaml

inp = """\
[ 42 ]
hello
"""
with pytest.raises(yaml.parser.ParserError):
d = list(round_trip_load_all(inp, version=(1, 2))) # NOQA

def test_yunk_after_explicit_document_end(self) -> None:
from ruamel import yaml

inp = """\
hello: world
... this is no comment
"""
with pytest.raises(yaml.parser.ParserError):
d = list(round_trip_load_all(inp, version=(1, 2))) # NOQA

def test_multi_doc_ends_only_1_1(self) -> None:
from ruamel import yaml

Expand Down
56 changes: 56 additions & 0 deletions _test/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,62 @@ def test_issue_459(self) -> None:
data = yaml.load(out_stream.getvalue())
assert data[0]['data'] == MYOBJ['data']

def test_issue_461(self) -> None:
from ruamel.yaml import YAML

yaml = YAML()

inp = dedent(
"""
first name: Roy
last name: Rogers
city: somewhere
"""
)
yaml = YAML()
data = yaml.load(inp)
data.pop('last name')
assert data.pop('not there', 'xxx') == 'xxx'
data.insert(1, 'last name', 'Beaty', comment='he has seen things')

def test_issue_463(self) -> None:
import sys
from ruamel.yaml.compat import StringIO
from ruamel.yaml import YAML

yaml = YAML()

inp = dedent(
"""
first_name: Art
"""
)
data = yaml.load(inp)
_ = data.merge
data.insert(0, 'some_key', 'test')
yaml.dump(data, sys.stdout)
buf = StringIO()
yaml.dump(data, buf)
exp = dedent(
"""
some_key: test
first_name: Art
"""
)
assert buf.getvalue() == exp

def test_issue_464(self) -> None:
# document end marker without newline threw error in 0.17.27
from ruamel.yaml import YAML

yaml = YAML()
yaml.load('---\na: True\n...')

def test_issue_467(self) -> None:
import ruamel.yaml

yaml = ruamel.yaml.YAML()
yaml.constructor.add_constructor(yaml.resolver.DEFAULT_MAPPING_TAG, lambda x, y: None)

# @pytest.mark.xfail(strict=True, reason='bla bla', raises=AssertionError)
# def test_issue_ xxx(self) -> None:
Expand Down
26 changes: 26 additions & 0 deletions _test/test_literal.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,29 @@ def test_rt_non_root_literal_scalar(self) -> None:
ys = ys.format(s)
d = yaml.load(ys)
yaml.dump(d, compare=ys)

def test_regular_spaces(self) -> None:
import ruamel.yaml

yaml = ruamel.yaml.YAML()
ys = "key: |\n\n\n content\n"
d = yaml.load(ys)
assert d['key'] == '\n\ncontent\n'

def test_irregular_spaces_content(self) -> None:
import ruamel.yaml

yaml = ruamel.yaml.YAML()
ys = "key: |\n \n \n irregular content\n"
with pytest.raises(ruamel.yaml.scanner.ScannerError):
d = yaml.load(ys)
print(d)

def test_irregular_spaces_comment(self) -> None:
import ruamel.yaml

yaml = ruamel.yaml.YAML()
ys = "key: |\n \n \n # comment\n"
with pytest.raises(ruamel.yaml.scanner.ScannerError):
d = yaml.load(ys)
print(d)
Loading

0 comments on commit bbb1df9

Please sign in to comment.