PEP 561: Clarify 4th step in Module Resolution Order (#2960)

This commit is contained in:
Martin Fischer 2023-01-13 09:43:43 +01:00 committed by GitHub
parent 26d2f2bff8
commit d8ce90756f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -182,6 +182,7 @@ laid out as follows::
└── hexagon
   └── __init__.pyi
.. _mro:
Type Checker Module Resolution Order
------------------------------------
@ -200,8 +201,10 @@ resolve modules containing type information:
3. Stub packages - these packages SHOULD supersede any installed inline
package. They can be found at ``foopkg-stubs`` for package ``foopkg``.
4. Inline packages - if there is nothing overriding the installed
package, *and* it opts into type checking, inline types SHOULD be used.
4. Packages with a ``py.typed`` marker file - if there is nothing overriding
the installed package, *and* it opts into type checking, the types
bundled with the package SHOULD be used (be they in ``.pyi`` type
stub files or inline in ``.py`` files).
5. Typeshed (if used) - Provides the stdlib types and several third party
libraries.
@ -274,6 +277,12 @@ Vlasovskikh, Nathaniel Smith, and Guido van Rossum.
Version History
===============
* 2023-01-13
* Clarify that the 4th step of the :ref:`Module Resolution Order <mro>` applies
to any package with a ``py.typed`` marker file (and not just
inline packages).
* 2021-09-20
* Clarify expectations and typechecker behavior for stub-only namespace packages