@@ -25,8 +25,8 @@ Final names
2525
2626You can use the ``typing.Final `` qualifier to indicate that
2727a name or attribute should not be reassigned, redefined, or
28- overridden. This is often useful for module and class level constants
29- as a way to prevent unintended modification. Mypy will prevent
28+ overridden. This is often useful for module and class- level
29+ constants to prevent unintended modification. Mypy will prevent
3030further assignments to final names in type-checked code:
3131
3232.. code-block :: python
@@ -70,23 +70,23 @@ You can use ``Final`` in one of these forms:
7070
7171 ID : Final[int ] = 1
7272
73- Here mypy will infer type ``int `` for ``ID ``.
73+ Here, mypy will infer type ``int `` for ``ID ``.
7474
7575* You can omit the type:
7676
7777 .. code-block :: python
7878
7979 ID : Final = 1
8080
81- Here mypy will infer type ``Literal[1] `` for ``ID ``. Note that unlike for
82- generic classes this is *not * the same as ``Final[Any] ``.
81+ Here, mypy will infer type ``Literal[1] `` for ``ID ``. Note that unlike for
82+ generic classes, this is *not * the same as ``Final[Any] ``.
8383
84- * In class bodies and stub files you can omit the right hand side and just write
84+ * In class bodies and stub files, you can omit the right- hand side and just write
8585 ``ID: Final[int] ``.
8686
8787* Finally, you can write ``self.id: Final = 1 `` (also optionally with
8888 a type in square brackets). This is allowed *only * in
89- :py:meth: `__init__ <object.__init__> ` methods, so that the final instance attribute is
89+ :py:meth: `__init__ <object.__init__> ` methods so the final instance attribute is
9090 assigned only once when an instance is created.
9191
9292Details of using ``Final ``
@@ -129,7 +129,7 @@ the scope of a final declaration automatically depending on whether it was
129129initialized in the class body or in :py:meth: `__init__ <object.__init__> `.
130130
131131A final attribute can't be overridden by a subclass (even with another
132- explicit final declaration). Note however that a final attribute can
132+ explicit final declaration). Note, however, that a final attribute can
133133override a read-only property:
134134
135135.. code-block :: python
@@ -176,12 +176,12 @@ overriding. You can use the ``typing.final`` decorator for this purpose:
176176 This ``@final `` decorator can be used with instance methods, class methods,
177177static methods, and properties.
178178
179- For overloaded methods you should add ``@final `` on the implementation
179+ For overloaded methods, you should add ``@final `` on the implementation
180180to make it final (or on the first overload in stubs):
181181
182182.. code-block :: python
183183
184- from typing import Any , overload
184+ from typing import final , overload
185185
186186 class Base :
187187 @overload
@@ -224,7 +224,7 @@ Here are some situations where using a final class may be useful:
224224
225225An abstract class that defines at least one abstract method or
226226property and has ``@final `` decorator will generate an error from
227- mypy, since those attributes could never be implemented.
227+ mypy since those attributes could never be implemented.
228228
229229.. code-block :: python
230230
0 commit comments