Skip to content

Commit 6477766

Browse files
committed
Address review
1 parent fbfe927 commit 6477766

26 files changed

+89
-87
lines changed

Doc/c-api/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ Exception Classes
733733
This creates a class object derived from :exc:`Exception` (accessible in C as
734734
:c:data:`PyExc_Exception`).
735735
736-
The :attr:`~class.__module__` attribute of the new class is set to the first part (up
736+
The :attr:`~type.__module__` attribute of the new class is set to the first part (up
737737
to the last dot) of the *name* argument, and the class name is set to the last
738738
part (after the last dot). The *base* argument can be used to specify alternate
739739
base classes; it can either be only one class or a tuple of classes. The *dict*

Doc/c-api/object.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,14 @@ Object Protocol
367367
The result will be ``1`` when at least one of the checks returns ``1``,
368368
otherwise it will be ``0``.
369369
370-
If *cls* has a :meth:`~class.__subclasscheck__` method, it will be called to
370+
If *cls* has a :meth:`~type.__subclasscheck__` method, it will be called to
371371
determine the subclass status as described in :pep:`3119`. Otherwise,
372372
*derived* is a subclass of *cls* if it is a direct or indirect subclass,
373-
i.e. contained in :attr:`cls.__mro__ <class.__mro__>`.
373+
i.e. contained in :attr:`cls.__mro__ <type.__mro__>`.
374374
375375
Normally only class objects, i.e. instances of :class:`type` or a derived
376376
class, are considered classes. However, objects can override this by having
377-
a :attr:`~class.__bases__` attribute (which must be a tuple of base classes).
377+
a :attr:`~type.__bases__` attribute (which must be a tuple of base classes).
378378
379379
380380
.. c:function:: int PyObject_IsInstance(PyObject *inst, PyObject *cls)
@@ -386,15 +386,15 @@ Object Protocol
386386
The result will be ``1`` when at least one of the checks returns ``1``,
387387
otherwise it will be ``0``.
388388
389-
If *cls* has a :meth:`~class.__instancecheck__` method, it will be called to
389+
If *cls* has a :meth:`~type.__instancecheck__` method, it will be called to
390390
determine the subclass status as described in :pep:`3119`. Otherwise, *inst*
391391
is an instance of *cls* if its class is a subclass of *cls*.
392392
393393
An instance *inst* can override what is considered its class by having a
394394
:attr:`~object.__class__` attribute.
395395
396396
An object *cls* can override if it is considered a class, and what its base
397-
classes are, by having a :attr:`~class.__bases__` attribute (which must be a tuple
397+
classes are, by having a :attr:`~type.__bases__` attribute (which must be a tuple
398398
of base classes).
399399
400400

Doc/c-api/type.rst

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Type Objects
5353
.. c:function:: PyObject* PyType_GetDict(PyTypeObject* type)
5454
5555
Return the type object's internal namespace, which is otherwise only
56-
exposed via a read-only proxy (:attr:`cls.__dict__ <class.__dict__>`).
56+
exposed via a read-only proxy (:attr:`cls.__dict__ <type.__dict__>`).
5757
This is a
5858
replacement for accessing :c:member:`~PyTypeObject.tp_dict` directly.
5959
The returned dictionary must be treated as read-only.
@@ -141,7 +141,7 @@ Type Objects
141141
Return true if *a* is a subtype of *b*.
142142
143143
This function only checks for actual subtypes, which means that
144-
:meth:`~class.__subclasscheck__` is not called on *b*. Call
144+
:meth:`~type.__subclasscheck__` is not called on *b*. Call
145145
:c:func:`PyObject_IsSubclass` to do the same check that :func:`issubclass`
146146
would do.
147147
@@ -176,31 +176,29 @@ Type Objects
176176
.. c:function:: PyObject* PyType_GetName(PyTypeObject *type)
177177
178178
Return the type's name. Equivalent to getting the type's
179-
:attr:`~class.__name__` attribute.
179+
:attr:`~type.__name__` attribute.
180180
181181
.. versionadded:: 3.11
182182
183183
.. c:function:: PyObject* PyType_GetQualName(PyTypeObject *type)
184184
185185
Return the type's qualified name. Equivalent to getting the
186-
type's :attr:`~class.__qualname__` attribute.
186+
type's :attr:`~type.__qualname__` attribute.
187187
188188
.. versionadded:: 3.11
189189
190190
.. c:function:: PyObject* PyType_GetFullyQualifiedName(PyTypeObject *type)
191191
192192
Return the type's fully qualified name. Equivalent to
193-
``f"{type.__module__}.{type.__qualname__}"``, or
194-
:attr:`type.__qualname__ <class.__qualname__>` if
195-
:attr:`type.__module__ <class.__module__>` is not a string or is equal to
196-
``"builtins"``.
193+
``f"{type.__module__}.{type.__qualname__}"``, or :attr:`type.__qualname__`
194+
if :attr:`type.__module__` is not a string or is equal to ``"builtins"``.
197195
198196
.. versionadded:: 3.13
199197
200198
.. c:function:: PyObject* PyType_GetModuleName(PyTypeObject *type)
201199
202200
Return the type's module name. Equivalent to getting the
203-
:attr:`type.__module__ <class.__module__>` attribute.
201+
:attr:`type.__module__` attribute.
204202
205203
.. versionadded:: 3.13
206204

Doc/c-api/typeobj.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -567,12 +567,12 @@ and :c:data:`PyType_Type` effectively act as defaults.)
567567

568568
For :ref:`statically allocated type objects <static-types>`,
569569
the *tp_name* field should contain a dot.
570-
Everything before the last dot is made accessible as the :attr:`~class.__module__`
570+
Everything before the last dot is made accessible as the :attr:`~type.__module__`
571571
attribute, and everything after the last dot is made accessible as the
572-
:attr:`~class.__name__` attribute.
572+
:attr:`~type.__name__` attribute.
573573

574574
If no dot is present, the entire :c:member:`~PyTypeObject.tp_name` field is made accessible as the
575-
:attr:`~class.__name__` attribute, and the :attr:`~class.__module__` attribute is undefined
575+
:attr:`~type.__name__` attribute, and the :attr:`~class.__module__` attribute is undefined
576576
(unless explicitly set in the dictionary, as explained above). This means your
577577
type will be impossible to pickle. Additionally, it will not be listed in
578578
module documentations created with pydoc.
@@ -1335,7 +1335,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
13351335
.. c:member:: const char* PyTypeObject.tp_doc
13361336
13371337
An optional pointer to a NUL-terminated C string giving the docstring for this
1338-
type object. This is exposed as the :attr:`~class.__doc__` attribute on the
1338+
type object. This is exposed as the :attr:`~type.__doc__` attribute on the
13391339
type and instances of the type.
13401340

13411341
**Inheritance:**
@@ -2036,7 +2036,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
20362036
A collection of subclasses. Internal use only. May be an invalid pointer.
20372037

20382038
To get a list of subclasses, call the Python method
2039-
:py:meth:`~class.__subclasses__`.
2039+
:py:meth:`~type.__subclasses__`.
20402040

20412041
.. versionchanged:: 3.12
20422042

Doc/extending/newtypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ An interesting advantage of using the :c:member:`~PyTypeObject.tp_members` table
296296
descriptors that are used at runtime is that any attribute defined this way can
297297
have an associated doc string simply by providing the text in the table. An
298298
application can use the introspection API to retrieve the descriptor from the
299-
class object, and get the doc string using its :attr:`~class.__doc__` attribute.
299+
class object, and get the doc string using its :attr:`~type.__doc__` attribute.
300300

301301
As with the :c:member:`~PyTypeObject.tp_methods` table, a sentinel entry with a :c:member:`~PyMethodDef.ml_name` value
302302
of ``NULL`` is required.

Doc/extending/newtypes_tutorial.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ only used for variable-sized objects and should otherwise be zero.
144144
If you want your type to be subclassable from Python, and your type has the same
145145
:c:member:`~PyTypeObject.tp_basicsize` as its base type, you may have problems with multiple
146146
inheritance. A Python subclass of your type will have to list your type first
147-
in its :attr:`~class.__bases__`, or else it will not be able to call your type's
147+
in its :attr:`~type.__bases__`, or else it will not be able to call your type's
148148
:meth:`~object.__new__` method without getting an error. You can avoid this problem by
149149
ensuring that your type has a larger value for :c:member:`~PyTypeObject.tp_basicsize` than its
150150
base type does. Most of the time, this will be true anyway, because either your

Doc/howto/annotations.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Your code will have to have a separate code path if the object
107107
you're examining is a class (``isinstance(o, type)``).
108108
In that case, best practice relies on an implementation detail
109109
of Python 3.9 and before: if a class has annotations defined,
110-
they are stored in the class's :attr:`~class.__dict__` dictionary. Since
110+
they are stored in the class's :attr:`~type.__dict__` dictionary. Since
111111
the class may or may not have annotations defined, best practice
112112
is to call the :meth:`~dict.get` method on the class dict.
113113

@@ -126,7 +126,7 @@ the type of ``ann`` using :func:`isinstance` before further
126126
examination.
127127

128128
Note that some exotic or malformed type objects may not have
129-
a :attr:`~class.__dict__` attribute, so for extra safety you may also wish
129+
a :attr:`~type.__dict__` attribute, so for extra safety you may also wish
130130
to use :func:`getattr` to access :attr:`!__dict__`.
131131

132132

@@ -247,5 +247,5 @@ on the class, you may observe unexpected behavior; see
247247
quirks by using :func:`annotationlib.get_annotations` on Python 3.14+ or
248248
:func:`inspect.get_annotations` on Python 3.10+. On earlier versions of
249249
Python, you can avoid these bugs by accessing the annotations from the
250-
class's :attr:`~class.__dict__`
250+
class's :attr:`~type.__dict__`
251251
(e.g., ``cls.__dict__.get('__annotations__', None)``).

Doc/howto/enum.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ The solution is to specify the module name explicitly as follows::
608608
the source, pickling will be disabled.
609609

610610
The new pickle protocol 4 also, in some circumstances, relies on
611-
:attr:`~class.__qualname__` being set to the location where pickle will be able
611+
:attr:`~type.__qualname__` being set to the location where pickle will be able
612612
to find the class. For example, if the class was made available in class
613613
SomeData in the global scope::
614614

Doc/library/abc.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ a helper class :class:`ABC` to alternatively define ABCs through inheritance:
9999
that you can customize the behavior of :func:`issubclass` further without the
100100
need to call :meth:`register` on every class you want to consider a
101101
subclass of the ABC. (This class method is called from the
102-
:meth:`~class.__subclasscheck__` method of the ABC.)
102+
:meth:`~type.__subclasscheck__` method of the ABC.)
103103

104104
This method should return ``True``, ``False`` or :data:`NotImplemented`. If
105105
it returns ``True``, the *subclass* is considered a subclass of this ABC.
@@ -149,7 +149,7 @@ a helper class :class:`ABC` to alternatively define ABCs through inheritance:
149149
The :meth:`__subclasshook__` class method defined here says that any class
150150
that has an :meth:`~iterator.__iter__` method in its
151151
:attr:`~object.__dict__` (or in that of one of its base classes, accessed
152-
via the :attr:`~class.__mro__` list) is considered a ``MyIterable`` too.
152+
via the :attr:`~type.__mro__` list) is considered a ``MyIterable`` too.
153153

154154
Finally, the last line makes ``Foo`` a virtual subclass of ``MyIterable``,
155155
even though it does not define an :meth:`~iterator.__iter__` method (it uses

Doc/library/collections.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ they add the ability to access fields by name instead of position index.
874874
``(1, 2)``, then ``x`` will be a required argument, ``y`` will default to
875875
``1``, and ``z`` will default to ``2``.
876876

877-
If *module* is defined, the :attr:`~class.__module__` attribute of the
877+
If *module* is defined, the :attr:`~type.__module__` attribute of the
878878
named tuple is set to that value.
879879

880880
Named tuple instances do not have per-instance dictionaries, so they are

0 commit comments

Comments
 (0)