Skip to content

Commit

Permalink
Doc: Add "fully qualified name" term to the glossary
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed Nov 17, 2023
1 parent 76dcfd5 commit 36cf2a9
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 32 deletions.
5 changes: 3 additions & 2 deletions Doc/c-api/type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ Type Objects
.. c:function:: PyObject* PyType_GetFullyQualifiedName(PyTypeObject *type)
Return the type's fully qualified name. Equivalent to getting the
type's :attr:`__fully_qualified_name__ <class.__fully_qualified_name__>` attribute.
Return the type's :term:`fully qualified name`. Equivalent to getting the
type's :attr:`__fully_qualified_name__ <class.__fully_qualified_name__>`
attribute.
.. versionadded:: 3.13
Expand Down
19 changes: 19 additions & 0 deletions Doc/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,25 @@ Glossary
division. Note that ``(-11) // 4`` is ``-3`` because that is ``-2.75``
rounded *downward*. See :pep:`238`.

fully qualified name
The fully qualified name is the entire dotted path to a class or a
module.

The :attr:`class.__fully_qualified_name__` attribute includes the module
name, except for built-in classes. Example::

>>> import collections
>>> collections.OrderedDict.__fully_qualified_name__
'collections.OrderedDict'

When used to refer to modules, the *fully qualified name* means the
entire dotted path to the module, including any parent packages,
e.g. ``email.mime.text``::

>>> import email.mime.text
>>> email.mime.text.__name__
'email.mime.text'

function
A series of statements which returns some value to a caller. It can also
be passed zero or more :term:`arguments <argument>` which may be used in
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/doctest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -587,13 +587,13 @@ doctest decides whether actual output matches an example's expected output:
.. data:: IGNORE_EXCEPTION_DETAIL

When specified, doctests expecting exceptions pass so long as an exception
of the expected type is raised, even if the details
(message and fully qualified exception name) don't match.
of the expected type is raised, even if the details (message and
:term:`fully qualified exception name <fully qualified name>`) don't match.

For example, an example expecting ``ValueError: 42`` will pass if the actual
exception raised is ``ValueError: 3*14``, but will fail if, say, a
:exc:`TypeError` is raised instead.
It will also ignore any fully qualified name included before the
It will also ignore any :term:`fully qualified name` included before the
exception class, which can vary between implementations and versions
of Python and the code/libraries in use.
Hence, all three of these variations will work with the flag specified:
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/email.contentmanager.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
found:

* the type itself (``typ``)
* the type's fully qualified name (``typ.__module__ + '.' +
typ.__qualname__``).
* the type's :term:`fully qualified name`
(:attr:`typ.__fully_qualified_name__ <class.__fully_qualified_name__>`).
* the type's qualname (``typ.__qualname__``)
* the type's name (``typ.__name__``).

Expand Down
12 changes: 6 additions & 6 deletions Doc/library/importlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ ABC hierarchy::
reloaded):

- :attr:`__name__`
The module's fully qualified name.
The module's :term:`fully qualified name`.
It is ``'__main__'`` for an executed module.

- :attr:`__file__`
Expand All @@ -377,8 +377,8 @@ ABC hierarchy::
as an indicator that the module is a package.

- :attr:`__package__`
The fully qualified name of the package the module is in (or the
empty string for a top-level module).
The :term:`fully qualified name` of the package the module is in
(or the empty string for a top-level module).
If the module is a package then this is the same as :attr:`__name__`.

- :attr:`__loader__`
Expand Down Expand Up @@ -1181,7 +1181,7 @@ find and load modules.

(:attr:`__name__`)

The module's fully qualified name.
The module's :term:`fully qualified name`.
The :term:`finder` should always set this attribute to a non-empty string.

.. attribute:: loader
Expand Down Expand Up @@ -1230,8 +1230,8 @@ find and load modules.

(: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 :term:`fully qualified name` of the package the module is in
(or the empty string for a top-level module).
If the module is a package then this is the same as :attr:`name`.

.. attribute:: has_location
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/inspect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
| | co_name | name with which this code |
| | | object was defined |
+-----------+-------------------+---------------------------+
| | co_qualname | fully qualified name with |
| | co_qualname | qualified name with |
| | | which this code object |
| | | was defined |
+-----------+-------------------+---------------------------+
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/logging.config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ otherwise, the context is used to determine what to instantiate.

The configuring dict is searched for the following keys:

* ``class`` (mandatory). This is the fully qualified name of the
* ``class`` (mandatory). This is the :term:`fully qualified name` of the
handler class.

* ``level`` (optional). The level of the handler.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/pickle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ the function's code, nor any of its function attributes are pickled. Thus the
defining module must be importable in the unpickling environment, and the module
must contain the named object, otherwise an exception will be raised. [#]_

Similarly, classes are pickled by fully qualified name, so the same restrictions in
Similarly, classes are pickled by :term:`fully qualified name`, so the same restrictions in
the unpickling environment apply. Note that none of the class's code or data is
pickled, so in the following example the class attribute ``attr`` is not
restored in the unpickling environment::
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5498,7 +5498,7 @@ types, where they are relevant. Some of these are not reported by the

.. attribute:: class.__fully_qualified_name__

The fully qualified name of the class instance:
The :term:`fully qualified name` of the class instance:
``f"{class.__module__}.{class.__qualname__}"``, or ``class.__qualname__`` if
``class.__module__`` is not a string or is equal to ``"builtins"``.

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/unittest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ Command-line options
test name using :meth:`fnmatch.fnmatchcase`; otherwise simple case-sensitive
substring matching is used.

Patterns are matched against the fully qualified test method name as
imported by the test loader.
Patterns are matched against the :term:`fully qualified test method name
<fully qualified name>`_ as imported by the test loader.
For example, ``-k foo`` matches ``foo_tests.SomeTest.test_something``,
``bar_tests.SomeTest.test_foo``, but not ``bar_tests.FooTest.test_something``.
Expand Down
3 changes: 2 additions & 1 deletion Doc/library/warnings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ the disposition of the match. Each entry is a tuple of the form (*action*,
category must be a subclass in order to match.

* *module* is a string containing a regular expression that the start of the
fully qualified module name must match, case-sensitively. In :option:`-W` and
:term:`fully qualified module name <fully qualified name>` must match,
case-sensitively. In :option:`-W` and
:envvar:`PYTHONWARNINGS`, *module* is a literal string that the
fully qualified module name must be equal to (case-sensitively), ignoring any
whitespace at the start or end of *module*.
Expand Down
2 changes: 1 addition & 1 deletion Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ indirectly) to mutable objects.
single: co_qualname (code object attribute)

Special read-only attributes: :attr:`co_name` gives the function name;
:attr:`co_qualname` gives the fully qualified function name;
:attr:`co_qualname` gives the qualified function name;
:attr:`co_argcount` is the total number of positional arguments
(including positional-only arguments and arguments with default values);
:attr:`co_posonlyargcount` is the number of positional-only arguments
Expand Down
10 changes: 5 additions & 5 deletions Doc/reference/import.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ See also :pep:`420` for the namespace package specification.
Searching
=========

To begin the search, Python needs the :term:`fully qualified <qualified name>`
name of the module (or package, but for the purposes of this discussion, the
To begin the search, Python needs the :term:`fully qualified name`
of the module (or package, but for the purposes of this discussion, the
difference is immaterial) being imported. This name may come from various
arguments to the :keyword:`import` statement, or from the parameters to the
:func:`importlib.import_module` or :func:`__import__` functions.
Expand Down Expand Up @@ -547,7 +547,7 @@ listed below.

.. attribute:: __name__

The ``__name__`` attribute must be set to the fully qualified name of
The ``__name__`` attribute must be set to the :term:`fully qualified name` of
the module. This name is used to uniquely identify the module in
the import system.

Expand Down Expand Up @@ -885,7 +885,7 @@ contribute portions to namespace packages, path entry finders must implement
the :meth:`~importlib.abc.PathEntryFinder.find_spec` method.

:meth:`~importlib.abc.PathEntryFinder.find_spec` takes two arguments: the
fully qualified name of the module being imported, and the (optional) target
:term:`fully qualified name` of the module being imported, and the (optional) target
module. ``find_spec()`` returns a fully populated spec for the module.
This spec will always have "loader" set (with one exception).

Expand All @@ -905,7 +905,7 @@ a list containing the portion.
implemented on the path entry finder, the legacy methods are ignored.

:meth:`!find_loader` takes one argument, the
fully qualified name of the module being imported. ``find_loader()``
:term:`fully qualified name` of the module being imported. ``find_loader()``
returns a 2-tuple where the first item is the loader and the second item
is a namespace :term:`portion`.

Expand Down
4 changes: 2 additions & 2 deletions Doc/using/cmdline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,8 @@ Miscellaneous options
whether the actual warning category of the message is a subclass of the
specified warning category.

The *module* field matches the (fully qualified) module name; this match is
case-sensitive.
The *module* field matches the :term:`fully qualified module name <fully
qualified name>`; this match is case-sensitive.

The *lineno* field matches the line number, where zero matches all line
numbers and is thus equivalent to an omitted line number.
Expand Down
8 changes: 4 additions & 4 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ Other Language Changes
equivalent of the :option:`-X frozen_modules <-X>` command-line option.
(Contributed by Yilei Yang in :gh:`111374`.)

* Add :attr:`__fully_qualified_name__ <class.__fully_qualified_name__>` read-only attribute
to types: the fully qualified type name.
* Add the :attr:`__fully_qualified_name__ <class.__fully_qualified_name__>`
read-only attribute to types: the :term:`fully qualified name` of the type.
(Contributed by Victor Stinner in :gh:`111696`.)


Expand Down Expand Up @@ -1186,8 +1186,8 @@ New Features
:exc:`KeyError` if the key missing.
(Contributed by Stefan Behnel and Victor Stinner in :gh:`111262`.)

* Add :c:func:`PyType_GetFullyQualifiedName` function: get the type's fully
qualified name. It is equivalent to getting the type's
* Add :c:func:`PyType_GetFullyQualifiedName` function: get the type's
:term:`fully qualified name`. It is equivalent to getting the type's
:attr:`__fully_qualified_name__ <class.__fully_qualified_name__>` attribute.
(Contributed by Victor Stinner in :gh:`111696`.)

Expand Down

0 comments on commit 36cf2a9

Please sign in to comment.