@@ -176,10 +176,7 @@ class Node(Context):
176176 __slots__ = ()
177177
178178 def __str__ (self ) -> str :
179- a = self .accept (mypy .strconv .StrConv (options = Options ()))
180- if a is None :
181- return repr (self )
182- return a
179+ return self .accept (mypy .strconv .StrConv (options = Options ()))
183180
184181 def str_with_options (self , options : Options ) -> str :
185182 a = self .accept (mypy .strconv .StrConv (options = options ))
@@ -875,7 +872,9 @@ def deserialize(cls, data: JsonDict) -> FuncDef:
875872
876873# All types that are both SymbolNodes and FuncBases. See the FuncBase
877874# docstring for the rationale.
878- SYMBOL_FUNCBASE_TYPES = (OverloadedFuncDef , FuncDef )
875+ # See https://github.com/python/mypy/pull/13607#issuecomment-1236357236
876+ # TODO: we want to remove this at some point and just use `FuncBase` ideally.
877+ SYMBOL_FUNCBASE_TYPES : Final = (OverloadedFuncDef , FuncDef )
879878
880879
881880class Decorator (SymbolNode , Statement ):
@@ -2575,6 +2574,11 @@ def fullname(self) -> str:
25752574 return self ._fullname
25762575
25772576
2577+ # All types that are both SymbolNodes and Expressions.
2578+ # Use when common children of them are needed.
2579+ SYMBOL_NODE_EXPRESSION_TYPES : Final = (TypeVarLikeExpr ,)
2580+
2581+
25782582class TypeVarExpr (TypeVarLikeExpr ):
25792583 """Type variable expression TypeVar(...).
25802584
@@ -3273,7 +3277,7 @@ def get_method(self, name: str) -> FuncBase | Decorator | None:
32733277 for cls in self .mro :
32743278 if name in cls .names :
32753279 node = cls .names [name ].node
3276- if isinstance (node , FuncBase ):
3280+ if isinstance (node , SYMBOL_FUNCBASE_TYPES ):
32773281 return node
32783282 elif isinstance (node , Decorator ): # Two `if`s make `mypyc` happy
32793283 return node
@@ -4032,7 +4036,8 @@ def __str__(self) -> str:
40324036 ):
40334037 a .append (" " + str (key ) + " : " + str (value ))
40344038 else :
4035- a .append (" <invalid item>" )
4039+ # Used in debugging:
4040+ a .append (" <invalid item>" ) # type: ignore[unreachable]
40364041 a = sorted (a )
40374042 a .insert (0 , "SymbolTable(" )
40384043 a [- 1 ] += ")"
0 commit comments