diff options
| author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-01-17 12:12:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-17 12:12:58 +0100 |
| commit | 700cd8ffd71d325a0363838096eac8b2fee30384 (patch) | |
| tree | 0cc51fb6a5298af8ac110aaf979aa08506d73fac | |
| parent | a815443f62faae05249621a396dcf0afd884a619 (diff) | |
| download | astroid-git-700cd8ffd71d325a0363838096eac8b2fee30384.tar.gz | |
Add typing to ``__str__``, ``__repr__`` and ``_repr_name`` (#1353)
| -rw-r--r-- | astroid/nodes/node_ng.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index eb2a5fd8..562ad8cb 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -174,7 +174,7 @@ class NodeNG: context.inferred[key] = tuple(results) return - def _repr_name(self): + def _repr_name(self) -> str: """Get a name for nice representation. This is either :attr:`name`, :attr:`attrname`, or the empty string. @@ -186,7 +186,7 @@ class NodeNG: return getattr(self, "name", "") or getattr(self, "attrname", "") return "" - def __str__(self): + def __str__(self) -> str: rname = self._repr_name() cname = type(self).__name__ if rname: @@ -212,7 +212,7 @@ class NodeNG: "fields": (",\n" + " " * alignment).join(result), } - def __repr__(self): + def __repr__(self) -> str: rname = self._repr_name() if rname: string = "<%(cname)s.%(rname)s l.%(lineno)s at 0x%(id)x>" |
