diff options
author | Anthon van der Neut <anthon@mnt.org> | 2017-01-23 12:23:47 +0100 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2017-01-23 12:23:47 +0100 |
commit | 610bebfbbc8887195f1ad9f52adbed7ffcf70876 (patch) | |
tree | 20567b150c64f93b051645be03312c0676de3e15 | |
parent | 5f73166ac799522dea0377044b4f1df12c27c331 (diff) | |
download | ruamel.yaml-0.13.11.tar.gz |
allow ':' in flow-style scalar when not followed by space0.13.11
-rw-r--r-- | README.rst | 5 | ||||
-rw-r--r-- | __init__.py | 2 | ||||
-rw-r--r-- | _test/test_fail.py | 13 | ||||
-rw-r--r-- | emitter.py | 2 | ||||
-rw-r--r-- | scanner.py | 11 | ||||
-rw-r--r-- | tox.ini | 2 |
6 files changed, 28 insertions, 7 deletions
@@ -18,6 +18,11 @@ ChangeLog .. should insert NEXT: at the beginning of line for next key +0.13.11 (2017-01-23): + - allow ':' in flow style scalars if not followed by space. Also don't + quote such scalar as this is no longer necessary. + - add python 3.6 manylinux wheel to PyPI + 0.13.10 (2017-01-22): - fix for issue 93, insert spurious blank line before single line comment between indented sequence elements (reported by Alex) diff --git a/__init__.py b/__init__.py index 40e77b5..4cbf3b2 100644 --- a/__init__.py +++ b/__init__.py @@ -9,7 +9,7 @@ from __future__ import absolute_import _package_data = dict( full_package_name="ruamel.yaml", - version_info=(0, 13, 10), + version_info=(0, 13, 11), author="Anthon van der Neut", author_email="a.van.der.neut@ruamel.eu", description="ruamel.yaml is a YAML parser/emitter that supports roundtrip preservation of comments, seq/map flow style, and map key order", # NOQA diff --git a/_test/test_fail.py b/_test/test_fail.py index 34516a0..300bfa6 100644 --- a/_test/test_fail.py +++ b/_test/test_fail.py @@ -212,3 +212,16 @@ class TestTagFailures: location: Germany language: python """) + + +class TestFlowValues: + def test_flow_value_with_colon(self): + round_trip("""\ + {a: bcd:efg} + """) + + @pytest.mark.xfail(strict=True) + def test_flow_value_with_colon_quoted(self): + round_trip("""\ + {a: 'bcd:efg'} + """) @@ -775,8 +775,8 @@ class Emitter(object): if ch in u',?[]{}': flow_indicators = True if ch == u':': - flow_indicators = True if followed_by_whitespace: + flow_indicators = True block_indicators = True if ch == u'#' and preceeded_by_whitespace: flow_indicators = True @@ -1344,10 +1344,13 @@ class Scanner(object): break while True: ch = self.peek(length) - if ch in u'\0 \t\r\n\x85\u2028\u2029' \ - or (not self.flow_level and ch == u':' and - self.peek(length+1) in u'\0 \t\r\n\x85\u2028\u2029') \ - or (self.flow_level and ch in u',:?[]{}'): + if (ch == u':' and + self.peek(length+1) not in u'\0 \t\r\n\x85\u2028\u2029'): + pass + elif (ch in u'\0 \t\r\n\x85\u2028\u2029' or + (not self.flow_level and ch == u':' and + self.peek(length+1) in u'\0 \t\r\n\x85\u2028\u2029') or + (self.flow_level and ch in u',:?[]{}')): break length += 1 # It's not clear what we should do with ':' in the flow context. @@ -20,4 +20,4 @@ commands = [flake8] show-source = True max-line-length = 95 -exclude = .hg,.git,.tox,dist,.cache,__pycache__,ruamel.zip2tar.egg-info +exclude = _test/lib,.hg,.git,.tox,dist,.cache,__pycache__,ruamel.zip2tar.egg-info |