@@ -230,7 +230,7 @@ def analyze_ref_expr(self, e: RefExpr, lvalue: bool = False) -> Type:
230230 or lvalue )
231231 else :
232232 if isinstance (node , PlaceholderNode ):
233- assert False , 'PlaceholderNode %r leaked to checker' % node .fullname ()
233+ assert False , 'PlaceholderNode %r leaked to checker' % node .fullname
234234 # Unknown reference; use any type implicitly to avoid
235235 # generating extra type errors.
236236 result = AnyType (TypeOfAny .from_error )
@@ -243,12 +243,12 @@ def analyze_var_ref(self, var: Var, context: Context) -> Type:
243243 if isinstance (var_type , Instance ):
244244 if self .is_literal_context () and var_type .last_known_value is not None :
245245 return var_type .last_known_value
246- if var .name () in {'True' , 'False' }:
247- return self .infer_literal_expr_type (var .name () == 'True' , 'builtins.bool' )
246+ if var .name in {'True' , 'False' }:
247+ return self .infer_literal_expr_type (var .name == 'True' , 'builtins.bool' )
248248 return var .type
249249 else :
250250 if not var .is_ready and self .chk .in_checked_function ():
251- self .chk .handle_cannot_determine_type (var .name () , context )
251+ self .chk .handle_cannot_determine_type (var .name , context )
252252 # Implicit 'Any' type.
253253 return AnyType (TypeOfAny .special_form )
254254
@@ -328,7 +328,7 @@ def visit_call_expr_inner(self, e: CallExpr, allow_none_return: bool = False) ->
328328 if isinstance (e .callee .node , TypeAlias ):
329329 target = get_proper_type (e .callee .node .target )
330330 if isinstance (target , Instance ):
331- fullname = target .type .fullname ()
331+ fullname = target .type .fullname
332332 # * Call to a method on object that has a full name (see
333333 # method_fullname() for details on supported objects);
334334 # get_method_hook() and get_method_signature_hook() will
@@ -386,12 +386,12 @@ def method_fullname(self, object_type: Type, method_name: str) -> Optional[str]:
386386
387387 type_name = None
388388 if isinstance (object_type , Instance ):
389- type_name = object_type .type .fullname ()
389+ type_name = object_type .type .fullname
390390 elif isinstance (object_type , (TypedDictType , LiteralType )):
391391 info = object_type .fallback .type .get_containing_type_info (method_name )
392- type_name = info .fullname () if info is not None else None
392+ type_name = info .fullname if info is not None else None
393393 elif isinstance (object_type , TupleType ):
394- type_name = tuple_fallback (object_type ).type .fullname ()
394+ type_name = tuple_fallback (object_type ).type .fullname
395395
396396 if type_name is not None :
397397 return '{}.{}' .format (type_name , method_name )
@@ -558,7 +558,7 @@ def try_infer_partial_type(self, e: CallExpr) -> None:
558558 partial_type .type is None ):
559559 # A partial None type -> can't infer anything.
560560 return
561- typename = partial_type .type .fullname ()
561+ typename = partial_type .type .fullname
562562 methodname = e .callee .name
563563 # Sometimes we can infer a full type for a partial List, Dict or Set type.
564564 # TODO: Don't infer argument expression twice.
@@ -575,7 +575,7 @@ def try_infer_partial_type(self, e: CallExpr) -> None:
575575 and e .arg_kinds == [ARG_POS ]):
576576 arg_type = get_proper_type (self .accept (e .args [0 ]))
577577 if isinstance (arg_type , Instance ):
578- arg_typename = arg_type .type .fullname ()
578+ arg_typename = arg_type .type .fullname
579579 if arg_typename in self .container_args [typename ][methodname ]:
580580 full_item_types = [
581581 make_simplified_union ([item_type , prev_type ])
@@ -801,7 +801,7 @@ def check_call(self,
801801 is_super = False , is_operator = True , msg = self .msg ,
802802 original_type = callee , chk = self .chk ,
803803 in_literal_context = self .is_literal_context ())
804- callable_name = callee .type .fullname () + ".__call__"
804+ callable_name = callee .type .fullname + ".__call__"
805805 # Apply method signature hook, if one exists
806806 call_function = self .transform_callee_type (
807807 callable_name , call_function , args , arg_kinds , context , arg_names , callee )
@@ -840,7 +840,7 @@ def check_callable_call(self,
840840 callable_name = callee .name
841841 ret_type = get_proper_type (callee .ret_type )
842842 if callee .is_type_obj () and isinstance (ret_type , Instance ):
843- callable_name = ret_type .type .fullname ()
843+ callable_name = ret_type .type .fullname
844844 if (isinstance (callable_node , RefExpr )
845845 and callable_node .fullname in ('enum.Enum' , 'enum.IntEnum' ,
846846 'enum.Flag' , 'enum.IntFlag' )):
@@ -853,13 +853,13 @@ def check_callable_call(self,
853853 and not callee .type_object ().fallback_to_any ):
854854 type = callee .type_object ()
855855 self .msg .cannot_instantiate_abstract_class (
856- callee .type_object ().name () , type .abstract_attributes ,
856+ callee .type_object ().name , type .abstract_attributes ,
857857 context )
858858 elif (callee .is_type_obj () and callee .type_object ().is_protocol
859859 # Exception for Type[...]
860860 and not callee .from_type_type ):
861861 self .chk .fail (message_registry .CANNOT_INSTANTIATE_PROTOCOL
862- .format (callee .type_object ().name () ), context )
862+ .format (callee .type_object ().name ), context )
863863
864864 formal_to_actual = map_actuals_to_formals (
865865 arg_kinds , arg_names ,
@@ -935,7 +935,7 @@ def analyze_type_type_callee(self, item: ProperType, context: Context) -> Type:
935935 return callee
936936 # We support Type of namedtuples but not of tuples in general
937937 if (isinstance (item , TupleType )
938- and tuple_fallback (item ).type .fullname () != 'builtins.tuple' ):
938+ and tuple_fallback (item ).type .fullname != 'builtins.tuple' ):
939939 return self .analyze_type_type_callee (tuple_fallback (item ), context )
940940
941941 self .msg .unsupported_type_type (item , context )
@@ -2180,8 +2180,8 @@ def dangerous_comparison(self, left: Type, right: Type,
21802180 return False
21812181 if isinstance (left , Instance ) and isinstance (right , Instance ):
21822182 # Special case some builtin implementations of AbstractSet.
2183- if (left .type .fullname () in OVERLAPPING_TYPES_WHITELIST and
2184- right .type .fullname () in OVERLAPPING_TYPES_WHITELIST ):
2183+ if (left .type .fullname in OVERLAPPING_TYPES_WHITELIST and
2184+ right .type .fullname in OVERLAPPING_TYPES_WHITELIST ):
21852185 abstract_set = self .chk .lookup_typeinfo ('typing.AbstractSet' )
21862186 left = map_instance_to_supertype (left , abstract_set )
21872187 right = map_instance_to_supertype (right , abstract_set )
@@ -2334,7 +2334,7 @@ def lookup_definer(typ: Instance, attr_name: str) -> Optional[str]:
23342334 """
23352335 for cls in typ .type .mro :
23362336 if cls .names .get (attr_name ):
2337- return cls .fullname ()
2337+ return cls .fullname
23382338 return None
23392339
23402340 left_type = get_proper_type (left_type )
@@ -2899,7 +2899,7 @@ def visit_reveal_expr(self, expr: RevealExpr) -> Type:
28992899 # calculated at semantic analysis time. Use it to pull out the
29002900 # corresponding subset of variables in self.chk.type_map
29012901 names_to_types = {
2902- var_node .name () : var_node .type for var_node in expr .local_nodes
2902+ var_node .name : var_node .type for var_node in expr .local_nodes
29032903 } if expr .local_nodes is not None else {}
29042904
29052905 self .msg .reveal_locals (names_to_types , expr )
@@ -2988,7 +2988,7 @@ class LongName(Generic[T]): ...
29882988 return self .apply_type_arguments_to_callable (tp , item .args , ctx )
29892989 elif (isinstance (item , TupleType ) and
29902990 # Tuple[str, int]() fails at runtime, only named tuples and subclasses work.
2991- tuple_fallback (item ).type .fullname () != 'builtins.tuple' ):
2991+ tuple_fallback (item ).type .fullname != 'builtins.tuple' ):
29922992 return type_object_type (tuple_fallback (item ).type , self .named_type )
29932993 elif isinstance (item , AnyType ):
29942994 return AnyType (TypeOfAny .from_another_any , source_any = item )
@@ -3793,7 +3793,7 @@ def visit_yield_from_expr(self, e: YieldFromExpr, allow_none_return: bool = Fals
37933793 # Determine the type of the entire yield from expression.
37943794 iter_type = get_proper_type (iter_type )
37953795 if (isinstance (iter_type , Instance ) and
3796- iter_type .type .fullname () == 'typing.Generator' ):
3796+ iter_type .type .fullname == 'typing.Generator' ):
37973797 expr_type = self .chk .get_generator_return_type (iter_type , False )
37983798 else :
37993799 # Non-Generators don't return anything from `yield from` expressions.
@@ -3906,7 +3906,7 @@ def visit_any(self, t: AnyType) -> bool:
39063906def has_coroutine_decorator (t : Type ) -> bool :
39073907 """Whether t came from a function decorated with `@coroutine`."""
39083908 t = get_proper_type (t )
3909- return isinstance (t , Instance ) and t .type .fullname () == 'typing.AwaitableGenerator'
3909+ return isinstance (t , Instance ) and t .type .fullname == 'typing.AwaitableGenerator'
39103910
39113911
39123912def is_async_def (t : Type ) -> bool :
@@ -3925,10 +3925,10 @@ def is_async_def(t: Type) -> bool:
39253925 # decorations.)
39263926 t = get_proper_type (t )
39273927 if (isinstance (t , Instance )
3928- and t .type .fullname () == 'typing.AwaitableGenerator'
3928+ and t .type .fullname == 'typing.AwaitableGenerator'
39293929 and len (t .args ) >= 4 ):
39303930 t = get_proper_type (t .args [3 ])
3931- return isinstance (t , Instance ) and t .type .fullname () == 'typing.Coroutine'
3931+ return isinstance (t , Instance ) and t .type .fullname == 'typing.Coroutine'
39323932
39333933
39343934def is_non_empty_tuple (t : Type ) -> bool :
@@ -4025,7 +4025,7 @@ def arg_approximate_similarity(actual: Type, formal: Type) -> bool:
40254025 def is_typetype_like (typ : ProperType ) -> bool :
40264026 return (isinstance (typ , TypeType )
40274027 or (isinstance (typ , FunctionLike ) and typ .is_type_obj ())
4028- or (isinstance (typ , Instance ) and typ .type .fullname () == "builtins.type" ))
4028+ or (isinstance (typ , Instance ) and typ .type .fullname == "builtins.type" ))
40294029
40304030 if isinstance (formal , CallableType ):
40314031 if isinstance (actual , (CallableType , Overloaded , TypeType )):
@@ -4205,7 +4205,7 @@ def custom_equality_method(typ: Type) -> bool:
42054205 method = typ .type .get ('__eq__' )
42064206 if method and isinstance (method .node , (SYMBOL_FUNCBASE_TYPES , Decorator , Var )):
42074207 if method .node .info :
4208- return not method .node .info .fullname () .startswith ('builtins.' )
4208+ return not method .node .info .fullname .startswith ('builtins.' )
42094209 return False
42104210 if isinstance (typ , UnionType ):
42114211 return any (custom_equality_method (t ) for t in typ .items )
@@ -4230,7 +4230,7 @@ def has_bytes_component(typ: Type, py2: bool = False) -> bool:
42304230 byte_types = {'builtins.bytes' , 'builtins.bytearray' }
42314231 if isinstance (typ , UnionType ):
42324232 return any (has_bytes_component (t ) for t in typ .items )
4233- if isinstance (typ , Instance ) and typ .type .fullname () in byte_types :
4233+ if isinstance (typ , Instance ) and typ .type .fullname in byte_types :
42344234 return True
42354235 return False
42364236
0 commit comments