PEP 673: Fix syntax highlighting (#2435)
This commit is contained in:
parent
dab4060126
commit
09a93fb76c
|
@ -322,7 +322,7 @@ have a ``LinkedList`` whose elements must be subclasses of the current class.
|
|||
# OK
|
||||
LinkedList[int](value=1, next=LinkedList[int](value=2))
|
||||
# Not OK
|
||||
LinkedList[int](value=1, next=LinkedList[str](value=”hello”))
|
||||
LinkedList[int](value=1, next=LinkedList[str](value="hello"))
|
||||
|
||||
|
||||
However, annotating the ``next`` attribute as ``LinkedList[T]`` allows invalid
|
||||
|
@ -411,7 +411,7 @@ This is equivalent to writing:
|
|||
|
||||
::
|
||||
|
||||
Self = TypeVar(“Self”, bound=”Container[Any]”)
|
||||
Self = TypeVar("Self", bound="Container[Any]")
|
||||
|
||||
class Container(Generic[T]):
|
||||
value: T
|
||||
|
@ -430,7 +430,7 @@ an object of generic type ``Container[T]``, ``Self`` is bound to
|
|||
int_container: Container[int]
|
||||
str_container: Container[str]
|
||||
reveal_type(int_container.set_value(42)) # => Container[int]
|
||||
reveal_type(str_container.set_value(“hello”)) # => Container[str]
|
||||
reveal_type(str_container.set_value("hello")) # => Container[str]
|
||||
|
||||
def object_with_generic_type(
|
||||
container: Container[T], value: T,
|
||||
|
|
Loading…
Reference in New Issue