Skip to content

Commit 9165833

Browse files
committed
feat: __repr__ method for RefExpr and NameExpr
The addition of these 2 simple reprs was helpful for me for debugging a compiler issue locally
1 parent 555edf3 commit 9165833

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mypy/nodes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,6 +1914,9 @@ def __init__(self) -> None:
19141914
# And same for TypeIs
19151915
self.type_is: mypy.types.Type | None = None
19161916

1917+
def __repr__(self) -> str:
1918+
return f"<{type(self).__name__} fullname={self.fullname} of {self.node} object at {hex(id(self))}>"
1919+
19171920
@property
19181921
def fullname(self) -> str:
19191922
return self._fullname
@@ -1939,6 +1942,9 @@ def __init__(self, name: str) -> None:
19391942
# Is this a l.h.s. of a special form assignment like typed dict or type variable?
19401943
self.is_special_form = False
19411944

1945+
def __repr__(self) -> str:
1946+
return f"<{type(self).__name__} fullname={self.fullname} special_form={self.is_special_form} of {self.node} object at {hex(id(self))}>"
1947+
19421948
def accept(self, visitor: ExpressionVisitor[T]) -> T:
19431949
return visitor.visit_name_expr(self)
19441950

0 commit comments

Comments
 (0)