From e49fe2c960480877453ae8d1da7ad8abfbf5071e Mon Sep 17 00:00:00 2001 From: Shen Yi Hong Date: Wed, 6 Nov 2024 18:39:29 +0800 Subject: [PATCH 1/3] fix: spelling of "implicitly" --- docs/source/generics.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/generics.rst b/docs/source/generics.rst index 9c0a308ee39a..818aa2983dce 100644 --- a/docs/source/generics.rst +++ b/docs/source/generics.rst @@ -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 @@ -663,7 +663,7 @@ 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 From 59a838325d4634f40c85e4815c3b44c9a7bf0805 Mon Sep 17 00:00:00 2001 From: Shen Yi Hong Date: Wed, 6 Nov 2024 18:41:27 +0800 Subject: [PATCH 2/3] fix: undefined instance attribute --- docs/source/generics.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/generics.rst b/docs/source/generics.rst index 818aa2983dce..8663de5a3156 100644 --- a/docs/source/generics.rst +++ b/docs/source/generics.rst @@ -668,7 +668,7 @@ the attribute as ``Final``, the class could still be made covariant: 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 From 62ccba9b43c4fa753acd581ffa352534386a733a Mon Sep 17 00:00:00 2001 From: Shen Yi Hong Date: Wed, 6 Nov 2024 19:43:33 +0800 Subject: [PATCH 3/3] fix: remove extra "p" --- docs/source/generics.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/generics.rst b/docs/source/generics.rst index 8663de5a3156..4ba6d322417d 100644 --- a/docs/source/generics.rst +++ b/docs/source/generics.rst @@ -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: ...