Skip to content

Commit

Permalink
Fix typos in generics.rst (#18110)
Browse files Browse the repository at this point in the history
Found some minor typos in `generics.rst`
  • Loading branch information
shenyih0ng authored Nov 6, 2024
1 parent 7788c21 commit 78fb78b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/source/generics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ example (Python 3.12 syntax):
from typing import Mapping, Iterator
# This is a generic subclass of Mapping
class MyMapp[KT, VT](Mapping[KT, VT]):
class MyMap[KT, VT](Mapping[KT, VT]):
def __getitem__(self, k: KT) -> VT: ...
def __iter__(self) -> Iterator[KT]: ...
def __len__(self) -> int: ...
Expand Down Expand Up @@ -641,7 +641,7 @@ infer the most flexible variance for each class type variable. Here

.. code-block:: python
class Box[T]: # this type is implilicitly covariant
class Box[T]: # this type is implicitly covariant
def __init__(self, content: T) -> None:
self._content = content
Expand All @@ -663,12 +663,12 @@ the attribute as ``Final``, the class could still be made covariant:
from typing import Final
class Box[T]: # this type is implilicitly covariant
class Box[T]: # this type is implicitly covariant
def __init__(self, content: T) -> None:
self.content: Final = content
def get_content(self) -> T:
return self._content
return self.content
When using the legacy syntax, mypy assumes that all user-defined generics
are invariant by default. To declare a given generic class as covariant or
Expand Down

0 comments on commit 78fb78b

Please sign in to comment.