diff --git a/mypy/semanal.py b/mypy/semanal.py index efd656682bc7..45aa8ae39041 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -4936,7 +4936,7 @@ def process_typevar_parameters( return None elif param_name == "bound": if has_values: - self.fail("TypeVar cannot have both values and an upper bound", context) + self.fail("TypeVar cannot have both constraints and a bound", context) return None tv_arg = self.get_typevarlike_argument("TypeVar", param_name, param_value, context) if tv_arg is None: diff --git a/test-data/unit/semanal-errors.test b/test-data/unit/semanal-errors.test index 7e1f737c61b2..26358958ce42 100644 --- a/test-data/unit/semanal-errors.test +++ b/test-data/unit/semanal-errors.test @@ -1062,7 +1062,7 @@ k = TypeVar('k', contravariant=1) # E: TypeVar "contravariant" may only be a lit [case testMoreInvalidTypevarArguments] from typing import TypeVar -T = TypeVar('T', int, str, bound=bool) # E: TypeVar cannot have both values and an upper bound +T = TypeVar('T', int, str, bound=bool) # E: TypeVar cannot have both constraints and a bound S = TypeVar('S', covariant=True, contravariant=True) \ # E: TypeVar cannot be both covariant and contravariant [builtins fixtures/bool.pyi]