@@ -20,7 +20,9 @@ Abstract
2020
2121This PEP introduces the concept of type defaults for type parameters,
2222including ``TypeVar ``, ``ParamSpec ``, and ``TypeVarTuple ``,
23- which act as defaults for type parameters for which no type is specified.
23+ which act as defaults for type parameters for which no type arguments
24+ are specified explicitly with `'[]' `, or implicitly without `'[]' `
25+ but with the type inference by an assigned value.
2426
2527Default type argument support is available in some popular languages
2628such as C++, TypeScript, and Rust. A survey of type parameter syntax in
@@ -34,13 +36,18 @@ Motivation
3436
3537::
3638
37- T = TypeVar("T", default=int) # This means that if no type is specified T = int
38-
39+ T = TypeVar("T", default=int) # This means that T = int if no type argument is specified explicitly
40+ # with `'[]'`, or implicitly without `'[]'` but with the type
41+ # inference by an assigned value.
3942 @dataclass
4043 class Box(Generic[T]):
4144 value: T | None = None
4245
43- reveal_type(Box()) # type is Box[int]
46+ # The type argument isn't specified.
47+ reveal_type(Box()) # type is Box[int]
48+
49+ # The type argument is specified with
50+ # the type inference by an assigned value
4451 reveal_type(Box(value="Hello World!")) # type is Box[str]
4552
4653One place this `regularly comes
0 commit comments