diff options
author | Jacob Walls <jacobtylerwalls@gmail.com> | 2023-05-13 17:11:43 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-13 17:11:43 -0400 |
commit | 5fa9089f1af6da65640e5ff81ae79207d039b4bd (patch) | |
tree | 43bf44c84b0ca7186a2b2057f50e27e9e13417e0 /astroid/nodes | |
parent | e1b577ab43a45e7ca0398cd73833a00539d74f18 (diff) | |
download | astroid-git-5fa9089f1af6da65640e5ff81ae79207d039b4bd.tar.gz |
Publicize `NodeNG.repr_name()` (#2176)
Diffstat (limited to 'astroid/nodes')
-rw-r--r-- | astroid/nodes/node_ng.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py index 31c842ee..977469df 100644 --- a/astroid/nodes/node_ng.py +++ b/astroid/nodes/node_ng.py @@ -190,20 +190,17 @@ class NodeNG: context.inferred[key] = tuple(results) return - def _repr_name(self) -> str: + def repr_name(self) -> str: """Get a name for nice representation. This is either :attr:`name`, :attr:`attrname`, or the empty string. - - :returns: The nice name. - :rtype: str """ if all(name not in self._astroid_fields for name in ("name", "attrname")): return getattr(self, "name", "") or getattr(self, "attrname", "") return "" def __str__(self) -> str: - rname = self._repr_name() + rname = self.repr_name() cname = type(self).__name__ if rname: string = "%(cname)s.%(rname)s(%(fields)s)" @@ -229,7 +226,7 @@ class NodeNG: } def __repr__(self) -> str: - rname = self._repr_name() + rname = self.repr_name() if rname: string = "<%(cname)s.%(rname)s l.%(lineno)s at 0x%(id)x>" else: |