Skip to content

Commit cf3db99

Browse files
authored
Copyedit final_attrs.rst (#17813)
1 parent 9ffb9dd commit cf3db99

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

docs/source/final_attrs.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Final names
2525

2626
You can use the ``typing.Final`` qualifier to indicate that
2727
a 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
3030
further 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

9292
Details of using ``Final``
@@ -129,7 +129,7 @@ the scope of a final declaration automatically depending on whether it was
129129
initialized in the class body or in :py:meth:`__init__ <object.__init__>`.
130130

131131
A 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
133133
override 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,
177177
static 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
180180
to 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

225225
An abstract class that defines at least one abstract method or
226226
property 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

Comments
 (0)