diff options
author | Anthon van der Neut <anthon@mnt.org> | 2017-04-19 15:13:02 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2017-04-19 15:13:02 +0200 |
commit | 870b961a3a6d72d8c7569cbc637c6cc553c1d907 (patch) | |
tree | 4185c36062b9b8c504075658b8dd5303285f3a20 /constructor.py | |
parent | e3663d2b81399576b5a4edca9820971bf801e66a (diff) | |
download | ruamel.yaml-870b961a3a6d72d8c7569cbc637c6cc553c1d907.tar.gz |
fix issue #116: Text not available in 3.5.0/3.5.10.14.8
If this solves the issue for you, please close it.
Diffstat (limited to 'constructor.py')
-rw-r--r-- | constructor.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/constructor.py b/constructor.py index a4c9331..42877e4 100644 --- a/constructor.py +++ b/constructor.py @@ -10,9 +10,6 @@ import re import sys import types -from typing import Any, Dict, List, Set, Generator # NOQA - - from ruamel.yaml.error import (MarkedYAMLError) from ruamel.yaml.nodes import * # NOQA from ruamel.yaml.nodes import (SequenceNode, MappingNode, ScalarNode) @@ -27,6 +24,10 @@ from ruamel.yaml.scalarstring import (PreservedScalarString, SingleQuotedScalarS from ruamel.yaml.scalarint import ScalarInt, BinaryInt, OctalInt, HexInt, HexCapsInt from ruamel.yaml.timestamp import TimeStamp +if sys.version_info >= (3, 5, 2): + from typing import Any, Dict, List, Set, Generator # NOQA + + __all__ = ['BaseConstructor', 'SafeConstructor', 'Constructor', 'ConstructorError', 'RoundTripConstructor'] @@ -933,8 +934,8 @@ class RoundTripConstructor(SafeConstructor): if underscore is not None: underscore[1] = value_su[2] == '_' underscore[2] = len(value_su[2:]) > 1 and value_su[-1] == '_' - return BinaryInt(sign*int(value_s[2:], 2), width=width, - underscore=underscore) # type: ignore + return BinaryInt(sign*int(value_s[2:], 2), width=width, # type: ignore + underscore=underscore) elif value_s.startswith('0x'): # default to lower-case if no a-fA-F in string if self.resolver.processing_version > (1, 1) and value_s[2] == '0': @@ -956,8 +957,8 @@ class RoundTripConstructor(SafeConstructor): if underscore is not None: underscore[1] = value_su[2] == '_' underscore[2] = len(value_su[2:]) > 1 and value_su[-1] == '_' - return OctalInt(sign*int(value_s[2:], 8), width=width, - underscore=underscore) # type: ignore + return OctalInt(sign*int(value_s[2:], 8), width=width, # type: ignore + underscore=underscore) elif self.resolver.processing_version != (1, 2) and value_s[0] == '0': return sign*int(value_s, 8) elif self.resolver.processing_version != (1, 2) and ':' in value_s: @@ -974,13 +975,13 @@ class RoundTripConstructor(SafeConstructor): if underscore is not None: # cannot have a leading underscore underscore[2] = len(value_su) > 1 and value_su[-1] == '_' - return ScalarInt(sign*int(value_s), width=len(value_s), - underscore=underscore) # type: ignore + return ScalarInt(sign*int(value_s), width=len(value_s), # type: ignore + underscore=underscore) elif underscore: # cannot have a leading underscore underscore[2] = len(value_su) > 1 and value_su[-1] == '_' - return ScalarInt(sign*int(value_s), width=None, - underscore=underscore) # type: ignore + return ScalarInt(sign*int(value_s), width=None, # type: ignore + underscore=underscore) else: return sign*int(value_s) |