Skip to content

Commit 700cd8f

Browse files
authored
Add typing to __str__, __repr__ and _repr_name (#1353)
1 parent a815443 commit 700cd8f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

astroid/nodes/node_ng.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def infer(self, context=None, **kwargs):
174174
context.inferred[key] = tuple(results)
175175
return
176176

177-
def _repr_name(self):
177+
def _repr_name(self) -> str:
178178
"""Get a name for nice representation.
179179
180180
This is either :attr:`name`, :attr:`attrname`, or the empty string.
@@ -186,7 +186,7 @@ def _repr_name(self):
186186
return getattr(self, "name", "") or getattr(self, "attrname", "")
187187
return ""
188188

189-
def __str__(self):
189+
def __str__(self) -> str:
190190
rname = self._repr_name()
191191
cname = type(self).__name__
192192
if rname:
@@ -212,7 +212,7 @@ def __str__(self):
212212
"fields": (",\n" + " " * alignment).join(result),
213213
}
214214

215-
def __repr__(self):
215+
def __repr__(self) -> str:
216216
rname = self._repr_name()
217217
if rname:
218218
string = "<%(cname)s.%(rname)s l.%(lineno)s at 0x%(id)x>"

0 commit comments

Comments
 (0)