Fixup indentation for docs on ModuleSpec attributes (#124681)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
Alex Waygood 2024-09-27 10:35:09 -07:00 committed by GitHub
parent 4b89c5ebfc
commit 6716dd1c33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1166,10 +1166,9 @@ find and load modules.
.. class:: ModuleSpec(name, loader, *, origin=None, loader_state=None, is_package=None) .. class:: ModuleSpec(name, loader, *, origin=None, loader_state=None, is_package=None)
A specification for a module's import-system-related state. This is A specification for a module's import-system-related state. This is
typically exposed as the module's :attr:`__spec__` attribute. In the typically exposed as the module's :attr:`__spec__` attribute. Many
descriptions below, the names in parentheses give the corresponding of these attributes are also available directly on a module: for example,
attribute available directly on the module object, ``module.__spec__.origin == module.__file__``. Note, however, that
e.g. ``module.__spec__.origin == module.__file__``. Note, however, that
while the *values* are usually equivalent, they can differ since there is while the *values* are usually equivalent, they can differ since there is
no synchronization between the two objects. For example, it is possible to update no synchronization between the two objects. For example, it is possible to update
the module's :attr:`__file__` at runtime and this will not be automatically the module's :attr:`__file__` at runtime and this will not be automatically
@ -1179,66 +1178,60 @@ find and load modules.
.. attribute:: name .. attribute:: name
(:attr:`__name__`) The module's fully qualified name
(see :attr:`__name__` attributes on modules).
The module's fully qualified name. The :term:`finder` should always set this attribute to a non-empty string.
The :term:`finder` should always set this attribute to a non-empty string.
.. attribute:: loader .. attribute:: loader
(:attr:`__loader__`) The :term:`loader` used to load the module
(see :attr:`__loader__` attributes on modules).
The :term:`loader` used to load the module. The :term:`finder` should always set this attribute.
The :term:`finder` should always set this attribute.
.. attribute:: origin .. attribute:: origin
(:attr:`__file__`) The location the :term:`loader` should use to load the module
(see :attr:`__file__` attributes on modules).
The location the :term:`loader` should use to load the module. For example, for modules loaded from a .py file this is the filename.
For example, for modules loaded from a .py file this is the filename. The :term:`finder` should always set this attribute to a meaningful value
The :term:`finder` should always set this attribute to a meaningful value for the :term:`loader` to use. In the uncommon case that there is not one
for the :term:`loader` to use. In the uncommon case that there is not one (like for namespace packages), it should be set to ``None``.
(like for namespace packages), it should be set to ``None``.
.. attribute:: submodule_search_locations .. attribute:: submodule_search_locations
(:attr:`__path__`) The list of locations where the package's submodules will be found
(see :attr:`__path__` attributes on modules).
The list of locations where the package's submodules will be found. Most of the time this is a single directory.
Most of the time this is a single directory. The :term:`finder` should set this attribute to a list, even an empty one, to indicate
The :term:`finder` should set this attribute to a list, even an empty one, to indicate to the import system that the module is a package. It should be set to ``None`` for
to the import system that the module is a package. It should be set to ``None`` for non-package modules. It is set automatically later to a special object for
non-package modules. It is set automatically later to a special object for namespace packages.
namespace packages.
.. attribute:: loader_state .. attribute:: loader_state
The :term:`finder` may set this attribute to an object containing additional, The :term:`finder` may set this attribute to an object containing additional,
module-specific data to use when loading the module. Otherwise it should be module-specific data to use when loading the module. Otherwise it should be
set to ``None``. set to ``None``.
.. attribute:: cached .. attribute:: cached
(:attr:`__cached__`) The filename of a compiled version of the module's code
(see :attr:`__cached__` attributes on modules).
The filename of a compiled version of the module's code. The :term:`finder` should always set this attribute but it may be ``None``
The :term:`finder` should always set this attribute but it may be ``None`` for modules that do not need compiled code stored.
for modules that do not need compiled code stored.
.. attribute:: parent .. attribute:: parent
(:attr:`__package__`) (Read-only) The fully qualified name of the package the module is in (or the
empty string for a top-level module).
(Read-only) The fully qualified name of the package the module is in (or the See :attr:`__package__` attributes on modules.
empty string for a top-level module). If the module is a package then this is the same as :attr:`name`.
If the module is a package then this is the same as :attr:`name`.
.. attribute:: has_location .. attribute:: has_location
``True`` if the spec's :attr:`origin` refers to a loadable location, ``True`` if the spec's :attr:`origin` refers to a loadable location,
``False`` otherwise. This value impacts how :attr:`origin` is interpreted ``False`` otherwise. This value impacts how :attr:`origin` is interpreted
and how the module's :attr:`__file__` is populated. and how the module's :attr:`__file__` is populated.
.. class:: AppleFrameworkLoader(name, path) .. class:: AppleFrameworkLoader(name, path)