stouputils.all_doctests.reexports module#
Consistency check for packages that re-export their submodules explicitly.
Explicit re-exports are what makes PEP 810 lazy imports possible, since a star import resolves every deferred name at once. The cost is that a new public function is easy to forget in the parent package, so this module compares each submodule against the package that re-exports it.
- module_public_names(module: ModuleType) list[str][source]#
List the public names a module defines itself, ignoring anything it merely imported.
Only objects carrying a __module__ are considered, so plain constants are out of scope.
- Parameters:
module (ModuleType) – Module to inspect
- Returns:
Names defined by that module, sorted
- Return type:
list[str]
Examples
>>> from stouputils.all_doctests import reexports >>> module_public_names(reexports) ['find_missing_reexports', 'module_public_names']
- find_missing_reexports(
- package: ModuleType,
Find names a submodule defines that its parent package does not expose at all.
A submodule the parent exposes nothing from counts as deliberately internal and is skipped, which is how modules such as
stouputils.configstay out of the flat namespace. A name the parent already binds to a sibling’s definition is a plain naming clash, not a missing re-export, so it is not reported here either. Submodules that cannot be imported are skipped, since optional dependencies may be absent.- Parameters:
package (ModuleType) – Root package to walk
- Returns:
Missing names, keyed by the submodule that defines them
- Return type:
dict[str, list[str]]
Examples
>>> import stouputils >>> find_missing_reexports(stouputils) {}