Skip to content

Commit 3af7662

Browse files
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 a0665e1 commit 3af7662

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
@@ -1912,6 +1912,9 @@ def __init__(self) -> None:
19121912
# And same for TypeIs
19131913
self.type_is: mypy.types.Type | None = None
19141914

1915+
def __repr__(self) -> str:
1916+
return f"<{type(self).__name__} fullname={self.fullname} of {self.node} object at {hex(id(self))}>"
1917+
19151918
@property
19161919
def fullname(self) -> str:
19171920
return self._fullname
@@ -1937,6 +1940,9 @@ def __init__(self, name: str) -> None:
19371940
# Is this a l.h.s. of a special form assignment like typed dict or type variable?
19381941
self.is_special_form = False
19391942

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

0 commit comments

Comments
 (0)