Skip to content

Commit afa2f6b

Browse files
committed
Fix 4
1 parent f93d1c0 commit afa2f6b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

mypy/checkexpr.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5245,6 +5245,18 @@ def visit_callable_type(self, t: CallableType) -> bool:
52455245
return False
52465246
return super().visit_callable_type(t)
52475247

5248+
def visit_type_var(self, t: TypeVarType) -> bool:
5249+
default = [t.default] if t.has_default() else []
5250+
return self.query_types([t.upper_bound, *default] + t.values)
5251+
5252+
def visit_param_spec(self, t: ParamSpecType) -> bool:
5253+
default = [t.default] if t.has_default() else []
5254+
return self.query_types([t.upper_bound, *default])
5255+
5256+
def visit_type_var_tuple(self, t: TypeVarTupleType) -> bool:
5257+
default = [t.default] if t.has_default() else []
5258+
return self.query_types([t.upper_bound, *default])
5259+
52485260

52495261
def has_coroutine_decorator(t: Type) -> bool:
52505262
"""Whether t came from a function decorated with `@coroutine`."""

mypy/types.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,12 @@ def new_unification_variable(cls, old: Self) -> Self:
548548
new_id = TypeVarId.new(meta_level=1)
549549
return old.copy_modified(id=new_id)
550550

551+
def has_default(self) -> bool:
552+
return not (
553+
isinstance(self.default, AnyType)
554+
and self.default.type_of_any == TypeOfAny.from_omitted_generics
555+
)
556+
551557

552558
class TypeVarType(TypeVarLikeType):
553559
"""Type that refers to a type variable."""

0 commit comments

Comments
 (0)