Skip to content

Commit b48cf0e

Browse files
[3.15] gh-89554: Document standard type objects in types as classes (GH-150676) (GH-150761)
Use the directive and the role "class" instead of "data" for classes exposed in the types module. (cherry picked from commit bc05544) Co-authored-by: Bernát Gábor <gaborjbernat@gmail.com>
1 parent 506b41d commit b48cf0e

4 files changed

Lines changed: 22 additions & 22 deletions

File tree

Doc/howto/a-conceptual-overview-of-asyncio.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ The terms "coroutine function" and "coroutine object" are often conflated
115115
as coroutine.
116116
That can be confusing!
117117
In this article, coroutine specifically refers to a coroutine object, or more
118-
precisely, an instance of :data:`types.CoroutineType` (native coroutine).
118+
precisely, an instance of :class:`types.CoroutineType` (native coroutine).
119119
Note that coroutines can also exist as instances of
120120
:class:`collections.abc.Coroutine` -- a distinction that matters for type
121121
checking.

Doc/library/types.rst

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ Standard names are defined for the following types:
150150
.. versionadded:: 3.10
151151

152152

153-
.. data:: FunctionType
154-
LambdaType
153+
.. class:: FunctionType
154+
LambdaType
155155

156156
The type of user-defined functions and functions created by
157157
:keyword:`lambda` expressions.
@@ -162,21 +162,21 @@ Standard names are defined for the following types:
162162
and is not raised for normal compilation.
163163

164164

165-
.. data:: GeneratorType
165+
.. class:: GeneratorType
166166

167167
The type of :term:`generator`-iterator objects, created by
168168
generator functions.
169169

170170

171-
.. data:: CoroutineType
171+
.. class:: CoroutineType
172172

173173
The type of :term:`coroutine` objects, created by
174174
:keyword:`async def` functions.
175175

176176
.. versionadded:: 3.5
177177

178178

179-
.. data:: AsyncGeneratorType
179+
.. class:: AsyncGeneratorType
180180

181181
The type of :term:`asynchronous generator`-iterator objects, created by
182182
asynchronous generator functions.
@@ -196,36 +196,36 @@ Standard names are defined for the following types:
196196
required by the initializer. The audit event only occurs for direct
197197
instantiation of code objects, and is not raised for normal compilation.
198198

199-
.. data:: CellType
199+
.. class:: CellType
200200

201201
The type for cell objects: such objects are used as containers for
202202
a function's :term:`closure variables <closure variable>`.
203203

204204
.. versionadded:: 3.8
205205

206206

207-
.. data:: MethodType
207+
.. class:: MethodType
208208

209209
The type of methods of user-defined class instances.
210210

211211

212-
.. data:: BuiltinFunctionType
213-
BuiltinMethodType
212+
.. class:: BuiltinFunctionType
213+
BuiltinMethodType
214214

215215
The type of built-in functions like :func:`len` or :func:`sys.exit`, and
216216
methods of built-in classes. (Here, the term "built-in" means "written in
217217
C".)
218218

219219

220-
.. data:: WrapperDescriptorType
220+
.. class:: WrapperDescriptorType
221221

222222
The type of methods of some built-in data types and base classes such as
223223
:meth:`object.__init__` or :meth:`object.__lt__`.
224224

225225
.. versionadded:: 3.7
226226

227227

228-
.. data:: MethodWrapperType
228+
.. class:: MethodWrapperType
229229

230230
The type of *bound* methods of some built-in data types and base classes.
231231
For example it is the type of :code:`object().__str__`.
@@ -240,14 +240,14 @@ Standard names are defined for the following types:
240240
.. versionadded:: 3.10
241241

242242

243-
.. data:: MethodDescriptorType
243+
.. class:: MethodDescriptorType
244244

245245
The type of methods of some built-in data types such as :meth:`str.join`.
246246

247247
.. versionadded:: 3.7
248248

249249

250-
.. data:: ClassMethodDescriptorType
250+
.. class:: ClassMethodDescriptorType
251251

252252
The type of *unbound* class methods of some built-in data types such as
253253
``dict.__dict__['fromkeys']``.
@@ -327,13 +327,13 @@ Standard names are defined for the following types:
327327
dynamically.
328328

329329

330-
.. data:: FrameType
330+
.. class:: FrameType
331331

332332
The type of :ref:`frame objects <frame-objects>` such as found in
333333
:attr:`tb.tb_frame <traceback.tb_frame>` if ``tb`` is a traceback object.
334334

335335

336-
.. data:: FrameLocalsProxyType
336+
.. class:: FrameLocalsProxyType
337337

338338
The type of frame locals proxy objects, as found on the
339339
:attr:`frame.f_locals` attribute.
@@ -343,7 +343,7 @@ Standard names are defined for the following types:
343343
.. seealso:: :pep:`667`
344344

345345

346-
.. data:: LazyImportType
346+
.. class:: LazyImportType
347347

348348
The type of lazy import proxy objects. These objects are created when a
349349
module is lazily imported and serve as placeholders until the module is
@@ -355,7 +355,7 @@ Standard names are defined for the following types:
355355
.. seealso:: :pep:`810`
356356

357357

358-
.. data:: GetSetDescriptorType
358+
.. class:: GetSetDescriptorType
359359

360360
The type of objects defined in extension modules with ``PyGetSetDef``, such
361361
as :attr:`FrameType.f_locals <frame.f_locals>` or ``array.array.typecode``.
@@ -364,7 +364,7 @@ Standard names are defined for the following types:
364364
:class:`property` type, but for classes defined in extension modules.
365365

366366

367-
.. data:: MemberDescriptorType
367+
.. class:: MemberDescriptorType
368368

369369
The type of objects defined in extension modules with ``PyMemberDef``, such
370370
as ``datetime.timedelta.days``. This type is used as descriptor for simple C

Doc/whatsnew/3.10.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,7 @@ Changes in the Python API
19281928
(Contributed by Yurii Karabas, Andrew Svetlov, Yury Selivanov and Kyle Stanley
19291929
in :issue:`42392`.)
19301930
1931-
* The :data:`types.FunctionType` constructor now inherits the current builtins
1931+
* The :class:`types.FunctionType` constructor now inherits the current builtins
19321932
if the *globals* dictionary has no ``"__builtins__"`` key, rather than using
19331933
``{"None": None}`` as builtins: same behavior as :func:`eval` and
19341934
:func:`exec` functions. Defining a function with ``def function(...): ...``

Doc/whatsnew/3.15.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ eager:
184184
import myapp.slow_module # lazy (matches filter)
185185
import json # eager (does not match filter)
186186
187-
The proxy type itself is available as :data:`types.LazyImportType` for code
187+
The proxy type itself is available as :class:`types.LazyImportType` for code
188188
that needs to detect lazy imports programmatically.
189189

190190
There are some restrictions on where the ``lazy`` keyword can be used. Lazy
@@ -1662,7 +1662,7 @@ types
16621662
-----
16631663

16641664
* Expose the write-through :func:`locals` proxy type
1665-
as :data:`types.FrameLocalsProxyType`.
1665+
as :class:`types.FrameLocalsProxyType`.
16661666
This represents the type of the :attr:`frame.f_locals` attribute,
16671667
as described in :pep:`667`.
16681668

0 commit comments

Comments
 (0)