Skip to content

feat: __repr__ method for RefExpr and NameExpr #19486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mypy/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,9 @@ def __init__(self) -> None:
# And same for TypeIs
self.type_is: mypy.types.Type | None = None

def __repr__(self) -> str:
return f"<{type(self).__name__} fullname={self.fullname} type={self.type_is} of {self.node} object at {hex(id(self))}>"

@property
def fullname(self) -> str:
return self._fullname
Expand All @@ -1939,6 +1942,9 @@ def __init__(self, name: str) -> None:
# Is this a l.h.s. of a special form assignment like typed dict or type variable?
self.is_special_form = False

def __repr__(self) -> str:
return f"<{type(self).__name__} fullname={self.fullname} type={self.type_is} special_form={self.is_special_form} of {self.node} object at {hex(id(self))}>"

def accept(self, visitor: ExpressionVisitor[T]) -> T:
return visitor.visit_name_expr(self)

Expand Down
Loading