@@ -230,7 +230,7 @@ def analyze_ref_expr(self, e: RefExpr, lvalue: bool = False) -> Type:
230
230
or lvalue )
231
231
else :
232
232
if isinstance (node , PlaceholderNode ):
233
- assert False , 'PlaceholderNode %r leaked to checker' % node .fullname ()
233
+ assert False , 'PlaceholderNode %r leaked to checker' % node .fullname
234
234
# Unknown reference; use any type implicitly to avoid
235
235
# generating extra type errors.
236
236
result = AnyType (TypeOfAny .from_error )
@@ -243,12 +243,12 @@ def analyze_var_ref(self, var: Var, context: Context) -> Type:
243
243
if isinstance (var_type , Instance ):
244
244
if self .is_literal_context () and var_type .last_known_value is not None :
245
245
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' )
248
248
return var .type
249
249
else :
250
250
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 )
252
252
# Implicit 'Any' type.
253
253
return AnyType (TypeOfAny .special_form )
254
254
@@ -328,7 +328,7 @@ def visit_call_expr_inner(self, e: CallExpr, allow_none_return: bool = False) ->
328
328
if isinstance (e .callee .node , TypeAlias ):
329
329
target = get_proper_type (e .callee .node .target )
330
330
if isinstance (target , Instance ):
331
- fullname = target .type .fullname ()
331
+ fullname = target .type .fullname
332
332
# * Call to a method on object that has a full name (see
333
333
# method_fullname() for details on supported objects);
334
334
# 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]:
386
386
387
387
type_name = None
388
388
if isinstance (object_type , Instance ):
389
- type_name = object_type .type .fullname ()
389
+ type_name = object_type .type .fullname
390
390
elif isinstance (object_type , (TypedDictType , LiteralType )):
391
391
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
393
393
elif isinstance (object_type , TupleType ):
394
- type_name = tuple_fallback (object_type ).type .fullname ()
394
+ type_name = tuple_fallback (object_type ).type .fullname
395
395
396
396
if type_name is not None :
397
397
return '{}.{}' .format (type_name , method_name )
@@ -558,7 +558,7 @@ def try_infer_partial_type(self, e: CallExpr) -> None:
558
558
partial_type .type is None ):
559
559
# A partial None type -> can't infer anything.
560
560
return
561
- typename = partial_type .type .fullname ()
561
+ typename = partial_type .type .fullname
562
562
methodname = e .callee .name
563
563
# Sometimes we can infer a full type for a partial List, Dict or Set type.
564
564
# TODO: Don't infer argument expression twice.
@@ -575,7 +575,7 @@ def try_infer_partial_type(self, e: CallExpr) -> None:
575
575
and e .arg_kinds == [ARG_POS ]):
576
576
arg_type = get_proper_type (self .accept (e .args [0 ]))
577
577
if isinstance (arg_type , Instance ):
578
- arg_typename = arg_type .type .fullname ()
578
+ arg_typename = arg_type .type .fullname
579
579
if arg_typename in self .container_args [typename ][methodname ]:
580
580
full_item_types = [
581
581
make_simplified_union ([item_type , prev_type ])
@@ -801,7 +801,7 @@ def check_call(self,
801
801
is_super = False , is_operator = True , msg = self .msg ,
802
802
original_type = callee , chk = self .chk ,
803
803
in_literal_context = self .is_literal_context ())
804
- callable_name = callee .type .fullname () + ".__call__"
804
+ callable_name = callee .type .fullname + ".__call__"
805
805
# Apply method signature hook, if one exists
806
806
call_function = self .transform_callee_type (
807
807
callable_name , call_function , args , arg_kinds , context , arg_names , callee )
@@ -840,7 +840,7 @@ def check_callable_call(self,
840
840
callable_name = callee .name
841
841
ret_type = get_proper_type (callee .ret_type )
842
842
if callee .is_type_obj () and isinstance (ret_type , Instance ):
843
- callable_name = ret_type .type .fullname ()
843
+ callable_name = ret_type .type .fullname
844
844
if (isinstance (callable_node , RefExpr )
845
845
and callable_node .fullname in ('enum.Enum' , 'enum.IntEnum' ,
846
846
'enum.Flag' , 'enum.IntFlag' )):
@@ -853,13 +853,13 @@ def check_callable_call(self,
853
853
and not callee .type_object ().fallback_to_any ):
854
854
type = callee .type_object ()
855
855
self .msg .cannot_instantiate_abstract_class (
856
- callee .type_object ().name () , type .abstract_attributes ,
856
+ callee .type_object ().name , type .abstract_attributes ,
857
857
context )
858
858
elif (callee .is_type_obj () and callee .type_object ().is_protocol
859
859
# Exception for Type[...]
860
860
and not callee .from_type_type ):
861
861
self .chk .fail (message_registry .CANNOT_INSTANTIATE_PROTOCOL
862
- .format (callee .type_object ().name () ), context )
862
+ .format (callee .type_object ().name ), context )
863
863
864
864
formal_to_actual = map_actuals_to_formals (
865
865
arg_kinds , arg_names ,
@@ -935,7 +935,7 @@ def analyze_type_type_callee(self, item: ProperType, context: Context) -> Type:
935
935
return callee
936
936
# We support Type of namedtuples but not of tuples in general
937
937
if (isinstance (item , TupleType )
938
- and tuple_fallback (item ).type .fullname () != 'builtins.tuple' ):
938
+ and tuple_fallback (item ).type .fullname != 'builtins.tuple' ):
939
939
return self .analyze_type_type_callee (tuple_fallback (item ), context )
940
940
941
941
self .msg .unsupported_type_type (item , context )
@@ -2180,8 +2180,8 @@ def dangerous_comparison(self, left: Type, right: Type,
2180
2180
return False
2181
2181
if isinstance (left , Instance ) and isinstance (right , Instance ):
2182
2182
# 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 ):
2185
2185
abstract_set = self .chk .lookup_typeinfo ('typing.AbstractSet' )
2186
2186
left = map_instance_to_supertype (left , abstract_set )
2187
2187
right = map_instance_to_supertype (right , abstract_set )
@@ -2334,7 +2334,7 @@ def lookup_definer(typ: Instance, attr_name: str) -> Optional[str]:
2334
2334
"""
2335
2335
for cls in typ .type .mro :
2336
2336
if cls .names .get (attr_name ):
2337
- return cls .fullname ()
2337
+ return cls .fullname
2338
2338
return None
2339
2339
2340
2340
left_type = get_proper_type (left_type )
@@ -2899,7 +2899,7 @@ def visit_reveal_expr(self, expr: RevealExpr) -> Type:
2899
2899
# calculated at semantic analysis time. Use it to pull out the
2900
2900
# corresponding subset of variables in self.chk.type_map
2901
2901
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
2903
2903
} if expr .local_nodes is not None else {}
2904
2904
2905
2905
self .msg .reveal_locals (names_to_types , expr )
@@ -2988,7 +2988,7 @@ class LongName(Generic[T]): ...
2988
2988
return self .apply_type_arguments_to_callable (tp , item .args , ctx )
2989
2989
elif (isinstance (item , TupleType ) and
2990
2990
# 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' ):
2992
2992
return type_object_type (tuple_fallback (item ).type , self .named_type )
2993
2993
elif isinstance (item , AnyType ):
2994
2994
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
3793
3793
# Determine the type of the entire yield from expression.
3794
3794
iter_type = get_proper_type (iter_type )
3795
3795
if (isinstance (iter_type , Instance ) and
3796
- iter_type .type .fullname () == 'typing.Generator' ):
3796
+ iter_type .type .fullname == 'typing.Generator' ):
3797
3797
expr_type = self .chk .get_generator_return_type (iter_type , False )
3798
3798
else :
3799
3799
# Non-Generators don't return anything from `yield from` expressions.
@@ -3906,7 +3906,7 @@ def visit_any(self, t: AnyType) -> bool:
3906
3906
def has_coroutine_decorator (t : Type ) -> bool :
3907
3907
"""Whether t came from a function decorated with `@coroutine`."""
3908
3908
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'
3910
3910
3911
3911
3912
3912
def is_async_def (t : Type ) -> bool :
@@ -3925,10 +3925,10 @@ def is_async_def(t: Type) -> bool:
3925
3925
# decorations.)
3926
3926
t = get_proper_type (t )
3927
3927
if (isinstance (t , Instance )
3928
- and t .type .fullname () == 'typing.AwaitableGenerator'
3928
+ and t .type .fullname == 'typing.AwaitableGenerator'
3929
3929
and len (t .args ) >= 4 ):
3930
3930
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'
3932
3932
3933
3933
3934
3934
def is_non_empty_tuple (t : Type ) -> bool :
@@ -4025,7 +4025,7 @@ def arg_approximate_similarity(actual: Type, formal: Type) -> bool:
4025
4025
def is_typetype_like (typ : ProperType ) -> bool :
4026
4026
return (isinstance (typ , TypeType )
4027
4027
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" ))
4029
4029
4030
4030
if isinstance (formal , CallableType ):
4031
4031
if isinstance (actual , (CallableType , Overloaded , TypeType )):
@@ -4205,7 +4205,7 @@ def custom_equality_method(typ: Type) -> bool:
4205
4205
method = typ .type .get ('__eq__' )
4206
4206
if method and isinstance (method .node , (SYMBOL_FUNCBASE_TYPES , Decorator , Var )):
4207
4207
if method .node .info :
4208
- return not method .node .info .fullname () .startswith ('builtins.' )
4208
+ return not method .node .info .fullname .startswith ('builtins.' )
4209
4209
return False
4210
4210
if isinstance (typ , UnionType ):
4211
4211
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:
4230
4230
byte_types = {'builtins.bytes' , 'builtins.bytearray' }
4231
4231
if isinstance (typ , UnionType ):
4232
4232
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 :
4234
4234
return True
4235
4235
return False
4236
4236
0 commit comments