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 (
@@ -246,7 +246,7 @@ def visit_instance(self, t: Instance) -> Type:
246
246
def visit_type_var (self , t : TypeVarType ) -> Type :
247
247
repl = self .variables .get (t .id , t )
248
248
249
- if has_type_vars_default (repl ):
249
+ if has_type_var_like_default (repl ):
250
250
if repl in self .recursive_guard :
251
251
return repl
252
252
self .recursive_guard .add (repl )
Original file line number Diff line number Diff line change @@ -3425,7 +3425,7 @@ def has_type_vars(typ: Type) -> bool:
3425
3425
return typ .accept (HasTypeVars ())
3426
3426
3427
3427
3428
- class HasTypeVarDefault (BoolTypeQuery ):
3428
+ class HasTypeVarLikeDefault (BoolTypeQuery ):
3429
3429
def __init__ (self ) -> None :
3430
3430
super ().__init__ (ANY_STRATEGY )
3431
3431
self .skip_alias_target = True
@@ -3440,8 +3440,13 @@ def visit_param_spec(self, t: ParamSpecType) -> bool:
3440
3440
return t .has_default ()
3441
3441
3442
3442
3443
- def has_type_vars_default (typ : Type ) -> bool :
3444
- return typ .accept (HasTypeVarDefault ())
3443
+ # Use singleton since this is hot (note: call reset() before using)
3444
+ _has_type_var_like_default : Final = HasTypeVarLikeDefault ()
3445
+
3446
+
3447
+ def has_type_var_like_default (typ : Type ) -> bool :
3448
+ _has_type_var_like_default .reset ()
3449
+ return typ .accept (_has_type_var_like_default )
3445
3450
3446
3451
3447
3452
class HasParamSpecs (BoolTypeQuery ):
You can’t perform that action at this time.
0 commit comments