diff options
author | Anthon van der Neut <anthon@mnt.org> | 2021-03-09 09:02:50 +0100 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2021-03-09 09:02:50 +0100 |
commit | e73562c6f14d1d71a9fea174d58465e1b13f68af (patch) | |
tree | 309851cca7d411b31c27753555871d493282c7f0 /nodes.py | |
parent | 96839d9f64f4698bdc519cbfbd48d51178460714 (diff) | |
download | ruamel.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.py | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -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 |