Skip to content

Commit 72aac09

Browse files
committed
Fix some typing issues
1 parent aab6457 commit 72aac09

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

mypy/constraints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def _infer_constraints(
329329
if isinstance(actual, UnionType):
330330
actual = mypy.typeops.make_simplified_union(actual.items, keep_erased=True)
331331
if isinstance(actual, TypeVarType) and actual.has_default():
332-
actual = actual.default
332+
actual = get_proper_type(actual.default)
333333

334334
# Ignore Any types from the type suggestion engine to avoid them
335335
# causing us to infer Any in situations where a better job could

mypy/tvar_scope.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from copy import copy
4-
from typing import Generator
4+
from typing import Iterator
55

66
from mypy.nodes import (
77
ParamSpecExpr,
@@ -10,7 +10,7 @@
1010
TypeVarLikeExpr,
1111
TypeVarTupleExpr,
1212
)
13-
from mypy.type_visitor import SyntheticTypeVisitor, T
13+
from mypy.type_visitor import SyntheticTypeVisitor
1414
from mypy.types import (
1515
AnyType,
1616
CallableArgument,
@@ -44,93 +44,93 @@
4444
)
4545

4646

47-
class TypeVarLikeYielder(SyntheticTypeVisitor[Generator[TypeVarLikeType, None, None]]):
47+
class TypeVarLikeYielder(SyntheticTypeVisitor[Iterator[TypeVarLikeType]]):
4848
"""Yield all TypeVarLikeTypes in a type."""
4949

50-
def visit_type_var(self, t: TypeVarType) -> Generator[TypeVarLikeType, None, None]:
50+
def visit_type_var(self, t: TypeVarType) -> Iterator[TypeVarLikeType]:
5151
yield t
5252

53-
def visit_type_var_tuple(self, t: TypeVarTupleType) -> Generator[TypeVarLikeType, None, None]:
53+
def visit_type_var_tuple(self, t: TypeVarTupleType) -> Iterator[TypeVarLikeType]:
5454
yield t
5555

56-
def visit_param_spec(self, t: ParamSpecType) -> Generator[TypeVarLikeType, None, None]:
56+
def visit_param_spec(self, t: ParamSpecType) -> Iterator[TypeVarLikeType]:
5757
yield t
5858

59-
def visit_callable_type(self, t: CallableType) -> Generator[TypeVarLikeType, None, None]:
59+
def visit_callable_type(self, t: CallableType) -> Iterator[TypeVarLikeType]:
6060
for arg in t.arg_types:
6161
yield from arg.accept(self)
6262
yield from t.ret_type.accept(self)
6363

64-
def visit_instance(self, t: Instance) -> Generator[TypeVarLikeType, None, None]:
64+
def visit_instance(self, t: Instance) -> Iterator[TypeVarLikeType]:
6565
for arg in t.args:
6666
yield from arg.accept(self)
6767

68-
def visit_overloaded(self, t: Overloaded) -> Generator[TypeVarLikeType, None, None]:
68+
def visit_overloaded(self, t: Overloaded) -> Iterator[TypeVarLikeType]:
6969
for item in t.items:
7070
yield from item.accept(self)
7171

72-
def visit_tuple_type(self, t: TupleType) -> Generator[TypeVarLikeType, None, None]:
72+
def visit_tuple_type(self, t: TupleType) -> Iterator[TypeVarLikeType]:
7373
for item in t.items:
7474
yield from item.accept(self)
7575

76-
def visit_type_alias_type(self, t: TypeAliasType) -> Generator[TypeVarLikeType, None, None]:
76+
def visit_type_alias_type(self, t: TypeAliasType) -> Iterator[TypeVarLikeType]:
7777
for arg in t.args:
7878
yield from arg.accept(self)
7979

80-
def visit_typeddict_type(self, t: TypedDictType) -> Generator[TypeVarLikeType, None, None]:
80+
def visit_typeddict_type(self, t: TypedDictType) -> Iterator[TypeVarLikeType]:
8181
for arg in t.items.values():
8282
yield from arg.accept(self)
8383

84-
def visit_union_type(self, t: UnionType) -> Generator[TypeVarLikeType, None, None]:
84+
def visit_union_type(self, t: UnionType) -> Iterator[TypeVarLikeType]:
8585
for arg in t.items:
8686
yield from arg.accept(self)
8787

88-
def visit_type_type(self, t: TypeType) -> T:
88+
def visit_type_type(self, t: TypeType) -> Iterator[TypeVarLikeType]:
8989
yield from t.item.accept(self)
9090

91-
def visit_type_list(self, t: TypeList) -> T:
91+
def visit_type_list(self, t: TypeList) -> Iterator[TypeVarLikeType]:
9292
yield from ()
9393

94-
def visit_callable_argument(self, t: CallableArgument) -> T:
94+
def visit_callable_argument(self, t: CallableArgument) -> Iterator[TypeVarLikeType]:
9595
yield from ()
9696

97-
def visit_ellipsis_type(self, t: EllipsisType) -> T:
97+
def visit_ellipsis_type(self, t: EllipsisType) -> Iterator[TypeVarLikeType]:
9898
yield from ()
9999

100-
def visit_raw_expression_type(self, t: RawExpressionType) -> T:
100+
def visit_raw_expression_type(self, t: RawExpressionType) -> Iterator[TypeVarLikeType]:
101101
yield from ()
102102

103-
def visit_unbound_type(self, t: UnboundType) -> T:
103+
def visit_unbound_type(self, t: UnboundType) -> Iterator[TypeVarLikeType]:
104104
yield from ()
105105

106-
def visit_none_type(self, t: NoneType) -> T:
106+
def visit_none_type(self, t: NoneType) -> Iterator[TypeVarLikeType]:
107107
yield from ()
108108

109-
def visit_uninhabited_type(self, t: UninhabitedType) -> T:
109+
def visit_uninhabited_type(self, t: UninhabitedType) -> Iterator[TypeVarLikeType]:
110110
yield from ()
111111

112-
def visit_erased_type(self, t: ErasedType) -> T:
112+
def visit_erased_type(self, t: ErasedType) -> Iterator[TypeVarLikeType]:
113113
yield from ()
114114

115-
def visit_deleted_type(self, t: DeletedType) -> T:
115+
def visit_deleted_type(self, t: DeletedType) -> Iterator[TypeVarLikeType]:
116116
yield from ()
117117

118-
def visit_parameters(self, t: Parameters) -> T:
118+
def visit_parameters(self, t: Parameters) -> Iterator[TypeVarLikeType]:
119119
yield from ()
120120

121-
def visit_literal_type(self, t: LiteralType) -> T:
121+
def visit_literal_type(self, t: LiteralType) -> Iterator[TypeVarLikeType]:
122122
yield from ()
123123

124-
def visit_partial_type(self, t: PartialType) -> T:
124+
def visit_partial_type(self, t: PartialType) -> Iterator[TypeVarLikeType]:
125125
yield from ()
126126

127-
def visit_unpack_type(self, t: UnpackType) -> T:
127+
def visit_unpack_type(self, t: UnpackType) -> Iterator[TypeVarLikeType]:
128128
yield from ()
129129

130-
def visit_any(self, t: AnyType) -> Generator[TypeVarLikeType, None, None]:
130+
def visit_any(self, t: AnyType) -> Iterator[TypeVarLikeType]:
131131
yield from ()
132132

133-
def visit_placeholder_type(self, t: PlaceholderType) -> Generator[TypeVarLikeType, None, None]:
133+
def visit_placeholder_type(self, t: PlaceholderType) -> Iterator[TypeVarLikeType]:
134134
yield from ()
135135

136136

0 commit comments

Comments
 (0)