diff options
author | Anthon van der Neut <anthon@mnt.org> | 2021-05-31 08:36:28 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2021-05-31 08:36:28 +0200 |
commit | ea3d878ef8635120354cd59a1f31b97b05a3e09b (patch) | |
tree | 75883248966af6cd241cbcd75bc40ba1bc856b6d /constructor.py | |
parent | 35b81abf32f2567feba5957bc7c9d31782af3b1c (diff) | |
download | ruamel.yaml-ea3d878ef8635120354cd59a1f31b97b05a3e09b.tar.gz |
fix 385 (missing attribute) and mypy issues0.17.6
Diffstat (limited to 'constructor.py')
-rw-r--r-- | constructor.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/constructor.py b/constructor.py index 0a5db9b..53a3d41 100644 --- a/constructor.py +++ b/constructor.py @@ -545,10 +545,7 @@ class SafeConstructor(BaseConstructor): node.start_mark, ) try: - if hasattr(base64, 'decodebytes'): - return base64.decodebytes(value) - else: - return base64.decodestring(value) + return base64.decodebytes(value) except binascii.Error as exc: raise ConstructorError( None, @@ -804,10 +801,7 @@ class Constructor(SafeConstructor): node.start_mark, ) try: - if hasattr(base64, 'decodebytes'): - return base64.decodebytes(value) - else: - return base64.decodestring(value) + return base64.decodebytes(value) except binascii.Error as exc: raise ConstructorError( None, @@ -1068,12 +1062,14 @@ class RoundTripConstructor(SafeConstructor): """ def comment(self, idx): + # type: (Any) -> Any assert self.loader.comment_handling is not None x = self.scanner.comments[idx] x.set_assigned() return x def comments(self, list_of_comments, idx=None): + # type: (Any, Optional[Any]) -> Any # hand in the comment and optional pre, eol, post segment if list_of_comments is None: return [] @@ -1103,7 +1099,8 @@ class RoundTripConstructor(SafeConstructor): # NEWCMNT if node.comment is not None and node.comment[1]: # nprintf('>>>>nc1', node.comment) - lss.comment = self.comment(node.comment[1][0]) # EOL comment after | + # EOL comment after | + lss.comment = self.comment(node.comment[1][0]) # type: ignore return lss if node.style == '>' and isinstance(node.value, str): fold_positions = [] # type: List[int] @@ -1121,7 +1118,8 @@ class RoundTripConstructor(SafeConstructor): # NEWCMNT if node.comment is not None and node.comment[1]: # nprintf('>>>>nc2', node.comment) - lss.comment = self.comment(node.comment[1][0]) # EOL comment after > + # EOL comment after > + lss.comment = self.comment(node.comment[1][0]) # type: ignore if fold_positions: fss.fold_pos = fold_positions # type: ignore return fss |