Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,7 @@ def check_unbound_return_typevar(self, typ: CallableType) -> None:
"Consider using the upper bound "
f"{format_type(typ.ret_type.upper_bound, self.options)} instead",
context=typ.ret_type,
code=TYPE_VAR,
)

def check_default_params(self, item: FuncItem, body_is_trivial: bool | None = None) -> None:
Expand Down
3 changes: 3 additions & 0 deletions test-data/unit/check-typevar-unbound.test
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def g() -> U: # E: A function returning TypeVar should receive at least one argu
# N: Consider using the upper bound "int" instead
...

def g2() -> U: # type: ignore[type-var]
...

V = TypeVar('V', int, str)

def h() -> V: # E: A function returning TypeVar should receive at least one argument containing the same TypeVar
Expand Down
Loading