File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 44
44
flatten_nested_unions ,
45
45
get_proper_type ,
46
46
has_param_specs ,
47
- has_type_vars_default ,
47
+ has_type_var_like_default ,
48
48
remove_trivial ,
49
49
)
50
50
from mypy .typevartuples import (
@@ -266,7 +266,7 @@ def visit_type_var(self, t: TypeVarType) -> Type:
266
266
t = t .copy_modified (upper_bound = t .upper_bound .accept (self ))
267
267
repl = self .variables .get (t .id , t )
268
268
269
- if has_type_vars_default (repl ):
269
+ if has_type_var_like_default (repl ):
270
270
if repl in self .recursive_guard :
271
271
return repl
272
272
self .recursive_guard .add (repl )
Original file line number Diff line number Diff line change @@ -3421,7 +3421,7 @@ def has_type_vars(typ: Type) -> bool:
3421
3421
return typ .accept (HasTypeVars ())
3422
3422
3423
3423
3424
- class HasTypeVarDefault (BoolTypeQuery ):
3424
+ class HasTypeVarLikeDefault (BoolTypeQuery ):
3425
3425
def __init__ (self ) -> None :
3426
3426
super ().__init__ (ANY_STRATEGY )
3427
3427
self .skip_alias_target = True
@@ -3436,8 +3436,13 @@ def visit_param_spec(self, t: ParamSpecType) -> bool:
3436
3436
return t .has_default ()
3437
3437
3438
3438
3439
- def has_type_vars_default (typ : Type ) -> bool :
3440
- return typ .accept (HasTypeVarDefault ())
3439
+ # Use singleton since this is hot (note: call reset() before using)
3440
+ _has_type_var_like_default : Final = HasTypeVarLikeDefault ()
3441
+
3442
+
3443
+ def has_type_var_like_default (typ : Type ) -> bool :
3444
+ _has_type_var_like_default .reset ()
3445
+ return typ .accept (_has_type_var_like_default )
3441
3446
3442
3447
3443
3448
class HasParamSpecs (BoolTypeQuery ):
You can’t perform that action at this time.
0 commit comments