summaryrefslogtreecommitdiff
path: root/nodes.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2021-03-09 09:02:50 +0100
committerAnthon van der Neut <anthon@mnt.org>2021-03-09 09:02:50 +0100
commite73562c6f14d1d71a9fea174d58465e1b13f68af (patch)
tree309851cca7d411b31c27753555871d493282c7f0 /nodes.py
parent96839d9f64f4698bdc519cbfbd48d51178460714 (diff)
downloadruamel.yaml-e73562c6f14d1d71a9fea174d58465e1b13f68af.tar.gz
remove python 2 specific code
add future deprecation warning to old style functions
Diffstat (limited to 'nodes.py')
-rw-r--r--nodes.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/nodes.py b/nodes.py
index da86e9c..f51f989 100644
--- a/nodes.py
+++ b/nodes.py
@@ -1,9 +1,8 @@
# coding: utf-8
-from __future__ import print_function
-
import sys
-from .compat import string_types
+
+from ruamel.yaml.compat import _F
if False: # MYPY
from typing import Dict, Any, Text # NOQA
@@ -30,18 +29,23 @@ class Node(object):
# elif len(value) == 1:
# value = '<1 item>'
# else:
- # value = '<%d items>' % len(value)
+ # value = f'<{len(value)} items>'
# else:
# if len(value) > 75:
- # value = repr(value[:70]+u' ... ')
+ # value = repr(value[:70]+' ... ')
# else:
# value = repr(value)
value = repr(value)
- return '%s(tag=%r, value=%s)' % (self.__class__.__name__, self.tag, value)
+ return _F(
+ '{class_name!s}(tag={self_tag!r}, value={value!s})',
+ class_name=self.__class__.__name__,
+ self_tag=self.tag,
+ value=value,
+ )
def dump(self, indent=0):
# type: (int) -> None
- if isinstance(self.value, string_types):
+ if isinstance(self.value, str):
sys.stdout.write(
'{}{}(tag={!r}, value={!r})\n'.format(
' ' * indent, self.__class__.__name__, self.tag, self.value