Skip to content

Commit a041e89

Browse files
authored
Update pep-0696.rst
1 parent bbfd434 commit a041e89

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

peps/pep-0696.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,19 @@ Motivation
4444
value: T | None = None
4545

4646
# The type argument isn't specified.
47-
reveal_type(Box()) # type is Box[int]
47+
reveal_type(Box()) # type is Box[int]
48+
49+
# The type argument is specified with '[]'.
50+
reveal_type(Box[str]()) # type is Box[str]
4851

4952
# The type argument is specified with
50-
# the type inference by an assigned value
53+
# the type inference by an assigned value.
5154
reveal_type(Box(value="Hello World!")) # type is Box[str]
5255

56+
# The type argument is specified with '[]' but not with the type
57+
# inference by an assigned value because '[]' is prioritized.
58+
reveal_type(Box[str](value="Hello World!")) # type is Box[str]
59+
5360
One place this `regularly comes
5461
up <https://github.com/python/typing/issues/975>`__ is ``Generator``. I
5562
propose changing the *stub definition* to something like::

0 commit comments

Comments
 (0)