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 (
@@ -250,7 +250,7 @@ def visit_type_var(self, t: TypeVarType) -> Type:
250
250
t = t .copy_modified (upper_bound = t .upper_bound .accept (self ))
251
251
repl = self .variables .get (t .id , t )
252
252
253
- if has_type_vars_default (repl ):
253
+ if has_type_var_like_default (repl ):
254
254
if repl in self .recursive_guard :
255
255
return repl
256
256
self .recursive_guard .add (repl )
Original file line number Diff line number Diff line change @@ -3416,7 +3416,7 @@ def has_type_vars(typ: Type) -> bool:
3416
3416
return typ .accept (HasTypeVars ())
3417
3417
3418
3418
3419
- class HasTypeVarDefault (BoolTypeQuery ):
3419
+ class HasTypeVarLikeDefault (BoolTypeQuery ):
3420
3420
def __init__ (self ) -> None :
3421
3421
super ().__init__ (ANY_STRATEGY )
3422
3422
self .skip_alias_target = True
@@ -3431,8 +3431,13 @@ def visit_param_spec(self, t: ParamSpecType) -> bool:
3431
3431
return t .has_default ()
3432
3432
3433
3433
3434
- def has_type_vars_default (typ : Type ) -> bool :
3435
- return typ .accept (HasTypeVarDefault ())
3434
+ # Use singleton since this is hot (note: call reset() before using)
3435
+ _has_type_var_like_default : Final = HasTypeVarLikeDefault ()
3436
+
3437
+
3438
+ def has_type_var_like_default (typ : Type ) -> bool :
3439
+ _has_type_var_like_default .reset ()
3440
+ return typ .accept (_has_type_var_like_default )
3436
3441
3437
3442
3438
3443
class HasParamSpecs (BoolTypeQuery ):
You can’t perform that action at this time.
0 commit comments