mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-10 04:36:40 +00:00
ruff format reflows long calls and normalises quotes, isort reorders the imports of the documentation lint package, SIM117 folds nested `with` statements into one parenthesised block, TC003 moves typing-only imports under `if TYPE_CHECKING`, the JavaScript linter replaces a `var`, and the YAML formatter rewraps five role files. None of it changes behaviour. One entry does more than that: the formatter had reflowed two calls in test_builder.py so their `# nocheck: cache-read` markers landed on the closing parenthesis, where they suppress nothing and the cache-read lint would have reported two real violations. Both calls are hoisted into a variable so the marker sits on the reading line again. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
31 lines
950 B
Python
31 lines
950 B
Python
"""Public names of a module, for the package shims that re-export one."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from types import ModuleType
|
|
|
|
|
|
def public_names(module: ModuleType) -> list[str]:
|
|
"""Return the names ``module`` defines itself, honouring its ``__all__``.
|
|
|
|
Listing ``dir()`` instead sweeps in whatever the module imported, so every
|
|
shim re-exported ``Path`` and ``Any``. Sphinx then found the same python
|
|
target in nine packages and reported 320 ambiguous cross-references.
|
|
|
|
Args:
|
|
module: the module whose public API is being re-exported.
|
|
"""
|
|
declared = getattr(module, "__all__", None)
|
|
if declared is not None:
|
|
return list(declared)
|
|
return [
|
|
name
|
|
for name in dir(module)
|
|
if not name.startswith("_")
|
|
and getattr(getattr(module, name), "__module__", module.__name__)
|
|
== module.__name__
|
|
]
|