Skip to content

Commit 1462b4e

Browse files
authored
Fix error code of note about unbound type variable (#21668)
The note used the default `misc` error code, which was different from the error message.
1 parent a6eadee commit 1462b4e

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

mypy/checker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,7 @@ def check_unbound_return_typevar(self, typ: CallableType) -> None:
18251825
"Consider using the upper bound "
18261826
f"{format_type(typ.ret_type.upper_bound, self.options)} instead",
18271827
context=typ.ret_type,
1828+
code=TYPE_VAR,
18281829
)
18291830

18301831
def check_default_params(self, item: FuncItem, body_is_trivial: bool | None = None) -> None:

test-data/unit/check-typevar-unbound.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ def g() -> U: # E: A function returning TypeVar should receive at least one argu
1313
# N: Consider using the upper bound "int" instead
1414
...
1515

16+
def g2() -> U: # type: ignore[type-var]
17+
...
18+
1619
V = TypeVar('V', int, str)
1720

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

0 commit comments

Comments
 (0)