@@ -21,7 +21,7 @@ The :mod:`collections` module has some concrete classes that derive from
21
21
ABCs; these can, of course, be further derived. In addition, the
22
22
:mod: `collections.abc ` submodule has some ABCs that can be used to test whether
23
23
a class or instance provides a particular interface, for example, if it is
24
- :term: `hashable ` or if it is a mapping.
24
+ :term: `hashable ` or if it is a :term: ` mapping ` .
25
25
26
26
27
27
This module provides the metaclass :class: `ABCMeta ` for defining ABCs and
@@ -30,19 +30,19 @@ a helper class :class:`ABC` to alternatively define ABCs through inheritance:
30
30
.. class :: ABC
31
31
32
32
A helper class that has :class: `ABCMeta ` as its metaclass. With this class,
33
- an abstract base class can be created by simply deriving from :class: `ABC `
33
+ an abstract base class can be created by simply deriving from :class: `! ABC `
34
34
avoiding sometimes confusing metaclass usage, for example::
35
35
36
36
from abc import ABC
37
37
38
38
class MyABC(ABC):
39
39
pass
40
40
41
- Note that the type of :class: `ABC ` is still :class: `ABCMeta `, therefore
42
- inheriting from :class: `ABC ` requires the usual precautions regarding
41
+ Note that the type of :class: `! ABC ` is still :class: `ABCMeta `, therefore
42
+ inheriting from :class: `! ABC ` requires the usual precautions regarding
43
43
metaclass usage, as multiple inheritance may lead to metaclass conflicts.
44
44
One may also define an abstract base class by passing the metaclass
45
- keyword and using :class: `ABCMeta ` directly, for example::
45
+ keyword and using :class: `! ABCMeta ` directly, for example::
46
46
47
47
from abc import ABCMeta
48
48
@@ -65,7 +65,7 @@ a helper class :class:`ABC` to alternatively define ABCs through inheritance:
65
65
implementations defined by the registering ABC be callable (not even via
66
66
:func: `super `). [# ]_
67
67
68
- Classes created with a metaclass of :class: `ABCMeta ` have the following method:
68
+ Classes created with a metaclass of :class: `! ABCMeta ` have the following method:
69
69
70
70
.. method :: register(subclass)
71
71
@@ -86,7 +86,7 @@ a helper class :class:`ABC` to alternatively define ABCs through inheritance:
86
86
Returns the registered subclass, to allow usage as a class decorator.
87
87
88
88
.. versionchanged :: 3.4
89
- To detect calls to :meth: `register `, you can use the
89
+ To detect calls to :meth: `! register `, you can use the
90
90
:func: `get_cache_token ` function.
91
91
92
92
You can also override this method in an abstract base class:
@@ -96,10 +96,10 @@ a helper class :class:`ABC` to alternatively define ABCs through inheritance:
96
96
(Must be defined as a class method.)
97
97
98
98
Check whether *subclass * is considered a subclass of this ABC. This means
99
- that you can customize the behavior of `` issubclass ` ` further without the
99
+ that you can customize the behavior of :func: ` issubclass ` further without the
100
100
need to call :meth: `register ` on every class you want to consider a
101
101
subclass of the ABC. (This class method is called from the
102
- :meth: `__subclasscheck__ ` method of the ABC.)
102
+ :meth: `~class. __subclasscheck__ ` method of the ABC.)
103
103
104
104
This method should return ``True ``, ``False `` or ``NotImplemented ``. If
105
105
it returns ``True ``, the *subclass * is considered a subclass of this ABC.
@@ -142,7 +142,7 @@ a helper class :class:`ABC` to alternatively define ABCs through inheritance:
142
142
143
143
The ABC ``MyIterable `` defines the standard iterable method,
144
144
:meth: `~iterator.__iter__ `, as an abstract method. The implementation given
145
- here can still be called from subclasses. The :meth: `get_iterator ` method
145
+ here can still be called from subclasses. The :meth: `! get_iterator ` method
146
146
is also part of the ``MyIterable `` abstract base class, but it does not have
147
147
to be overridden in non-abstract derived classes.
148
148
@@ -153,34 +153,34 @@ a helper class :class:`ABC` to alternatively define ABCs through inheritance:
153
153
154
154
Finally, the last line makes ``Foo `` a virtual subclass of ``MyIterable ``,
155
155
even though it does not define an :meth: `~iterator.__iter__ ` method (it uses
156
- the old-style iterable protocol, defined in terms of :meth: `__len__ ` and
156
+ the old-style iterable protocol, defined in terms of :meth: `~object. __len__ ` and
157
157
:meth: `~object.__getitem__ `). Note that this will not make ``get_iterator ``
158
158
available as a method of ``Foo ``, so it is provided separately.
159
159
160
160
161
161
162
162
163
- The :mod: `abc ` module also provides the following decorator:
163
+ The :mod: `! abc ` module also provides the following decorator:
164
164
165
165
.. decorator :: abstractmethod
166
166
167
167
A decorator indicating abstract methods.
168
168
169
169
Using this decorator requires that the class's metaclass is :class: `ABCMeta `
170
170
or is derived from it. A class that has a metaclass derived from
171
- :class: `ABCMeta ` cannot be instantiated unless all of its abstract methods
171
+ :class: `! ABCMeta ` cannot be instantiated unless all of its abstract methods
172
172
and properties are overridden. The abstract methods can be called using any
173
- of the normal 'super' call mechanisms. :func: `abstractmethod ` may be used
173
+ of the normal 'super' call mechanisms. :func: `! abstractmethod ` may be used
174
174
to declare abstract methods for properties and descriptors.
175
175
176
176
Dynamically adding abstract methods to a class, or attempting to modify the
177
177
abstraction status of a method or class once it is created, are only
178
178
supported using the :func: `update_abstractmethods ` function. The
179
- :func: `abstractmethod ` only affects subclasses derived using regular
180
- inheritance; "virtual subclasses" registered with the ABC's :meth: ` register `
181
- method are not affected.
179
+ :func: `! abstractmethod ` only affects subclasses derived using regular
180
+ inheritance; "virtual subclasses" registered with the ABC's
181
+ :meth: ` ~ABCMeta.register ` method are not affected.
182
182
183
- When :func: `abstractmethod ` is applied in combination with other method
183
+ When :func: `! abstractmethod ` is applied in combination with other method
184
184
descriptors, it should be applied as the innermost decorator, as shown in
185
185
the following usage examples::
186
186
@@ -216,7 +216,7 @@ The :mod:`abc` module also provides the following decorator:
216
216
217
217
In order to correctly interoperate with the abstract base class machinery,
218
218
the descriptor must identify itself as abstract using
219
- :attr: `__isabstractmethod__ `. In general, this attribute should be ``True ``
219
+ :attr: `! __isabstractmethod__ `. In general, this attribute should be ``True ``
220
220
if any of the methods used to compose the descriptor are abstract. For
221
221
example, Python's built-in :class: `property ` does the equivalent of::
222
222
@@ -236,7 +236,7 @@ The :mod:`abc` module also provides the following decorator:
236
236
super-call in a framework that uses cooperative
237
237
multiple-inheritance.
238
238
239
- The :mod: `abc ` module also supports the following legacy decorators:
239
+ The :mod: `! abc ` module also supports the following legacy decorators:
240
240
241
241
.. decorator :: abstractclassmethod
242
242
@@ -323,7 +323,7 @@ The :mod:`abc` module also supports the following legacy decorators:
323
323
...
324
324
325
325
326
- The :mod: `abc ` module also provides the following functions:
326
+ The :mod: `! abc ` module also provides the following functions:
327
327
328
328
.. function :: get_cache_token()
329
329
0 commit comments