Skip to content

Commit 6716dd1

Browse files
Fixup indentation for docs on ModuleSpec attributes (#124681)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parent 4b89c5e commit 6716dd1

File tree

1 file changed

+36
-43
lines changed

1 file changed

+36
-43
lines changed

Doc/library/importlib.rst

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,10 +1166,9 @@ find and load modules.
11661166
.. class:: ModuleSpec(name, loader, *, origin=None, loader_state=None, is_package=None)
11671167

11681168
A specification for a module's import-system-related state. This is
1169-
typically exposed as the module's :attr:`__spec__` attribute. In the
1170-
descriptions below, the names in parentheses give the corresponding
1171-
attribute available directly on the module object,
1172-
e.g. ``module.__spec__.origin == module.__file__``. Note, however, that
1169+
typically exposed as the module's :attr:`__spec__` attribute. Many
1170+
of these attributes are also available directly on a module: for example,
1171+
``module.__spec__.origin == module.__file__``. Note, however, that
11731172
while the *values* are usually equivalent, they can differ since there is
11741173
no synchronization between the two objects. For example, it is possible to update
11751174
the module's :attr:`__file__` at runtime and this will not be automatically
@@ -1179,66 +1178,60 @@ find and load modules.
11791178

11801179
.. attribute:: name
11811180

1182-
(:attr:`__name__`)
1183-
1184-
The module's fully qualified name.
1185-
The :term:`finder` should always set this attribute to a non-empty string.
1181+
The module's fully qualified name
1182+
(see :attr:`__name__` attributes on modules).
1183+
The :term:`finder` should always set this attribute to a non-empty string.
11861184

11871185
.. attribute:: loader
11881186

1189-
(:attr:`__loader__`)
1190-
1191-
The :term:`loader` used to load the module.
1192-
The :term:`finder` should always set this attribute.
1187+
The :term:`loader` used to load the module
1188+
(see :attr:`__loader__` attributes on modules).
1189+
The :term:`finder` should always set this attribute.
11931190

11941191
.. attribute:: origin
11951192

1196-
(:attr:`__file__`)
1197-
1198-
The location the :term:`loader` should use to load the module.
1199-
For example, for modules loaded from a .py file this is the filename.
1200-
The :term:`finder` should always set this attribute to a meaningful value
1201-
for the :term:`loader` to use. In the uncommon case that there is not one
1202-
(like for namespace packages), it should be set to ``None``.
1193+
The location the :term:`loader` should use to load the module
1194+
(see :attr:`__file__` attributes on modules).
1195+
For example, for modules loaded from a .py file this is the filename.
1196+
The :term:`finder` should always set this attribute to a meaningful value
1197+
for the :term:`loader` to use. In the uncommon case that there is not one
1198+
(like for namespace packages), it should be set to ``None``.
12031199

12041200
.. attribute:: submodule_search_locations
12051201

1206-
(:attr:`__path__`)
1207-
1208-
The list of locations where the package's submodules will be found.
1209-
Most of the time this is a single directory.
1210-
The :term:`finder` should set this attribute to a list, even an empty one, to indicate
1211-
to the import system that the module is a package. It should be set to ``None`` for
1212-
non-package modules. It is set automatically later to a special object for
1213-
namespace packages.
1202+
The list of locations where the package's submodules will be found
1203+
(see :attr:`__path__` attributes on modules).
1204+
Most of the time this is a single directory.
1205+
The :term:`finder` should set this attribute to a list, even an empty one, to indicate
1206+
to the import system that the module is a package. It should be set to ``None`` for
1207+
non-package modules. It is set automatically later to a special object for
1208+
namespace packages.
12141209

12151210
.. attribute:: loader_state
12161211

1217-
The :term:`finder` may set this attribute to an object containing additional,
1218-
module-specific data to use when loading the module. Otherwise it should be
1219-
set to ``None``.
1212+
The :term:`finder` may set this attribute to an object containing additional,
1213+
module-specific data to use when loading the module. Otherwise it should be
1214+
set to ``None``.
12201215

12211216
.. attribute:: cached
12221217

1223-
(:attr:`__cached__`)
1224-
1225-
The filename of a compiled version of the module's code.
1226-
The :term:`finder` should always set this attribute but it may be ``None``
1227-
for modules that do not need compiled code stored.
1218+
The filename of a compiled version of the module's code
1219+
(see :attr:`__cached__` attributes on modules).
1220+
The :term:`finder` should always set this attribute but it may be ``None``
1221+
for modules that do not need compiled code stored.
12281222

12291223
.. attribute:: parent
12301224

1231-
(:attr:`__package__`)
1232-
1233-
(Read-only) The fully qualified name of the package the module is in (or the
1234-
empty string for a top-level module).
1235-
If the module is a package then this is the same as :attr:`name`.
1225+
(Read-only) The fully qualified name of the package the module is in (or the
1226+
empty string for a top-level module).
1227+
See :attr:`__package__` attributes on modules.
1228+
If the module is a package then this is the same as :attr:`name`.
12361229

12371230
.. attribute:: has_location
12381231

1239-
``True`` if the spec's :attr:`origin` refers to a loadable location,
1240-
``False`` otherwise. This value impacts how :attr:`origin` is interpreted
1241-
and how the module's :attr:`__file__` is populated.
1232+
``True`` if the spec's :attr:`origin` refers to a loadable location,
1233+
``False`` otherwise. This value impacts how :attr:`origin` is interpreted
1234+
and how the module's :attr:`__file__` is populated.
12421235

12431236

12441237
.. class:: AppleFrameworkLoader(name, path)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy