Skip to content

Commit 920571e

Browse files
committed
chore(mypy): add docs/_ext to mypy_path + exclude docs/ for CI parity
tests/docs imports the widget framework as ``from widgets ...`` (the same way docs/conf.py loads it, via a sys.path insertion). Under mypy strict that raises "Cannot find implementation or library stub for module named 'widgets'". Listing ``docs/_ext`` under ``mypy_path`` alone -- rather than adding it to ``files`` -- avoids the reciprocal "source file found twice under different module names" error that would fire if mypy discovered the package via both its parent path and as a top-level module. ``exclude = ["^docs/"]`` is also required so that the CI invocation ``uv run mypy .`` -- which traverses every path under the current directory -- doesn't rediscover files in ``docs/_ext/widgets/`` under their ``docs._ext.`` prefix and error with the same "found twice" message. The widgets package is still fully type-checked via the ``mypy_path`` entry; the exclude only affects discovery-by-traversal. Both settings are needed from the moment the widgets package was introduced (17a406a); the ``mypy .`` failure was only surfaced by CI after tests/docs landed.
1 parent 6b46a51 commit 920571e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ files = [
115115
"src",
116116
"tests",
117117
]
118+
# ``docs/_ext`` is not in ``files`` to avoid double-naming the widgets package
119+
# (mypy would see it as both ``widgets`` and ``docs._ext.widgets``); the path
120+
# entry alone lets imports like ``from widgets import ...`` in tests resolve.
121+
# ``exclude`` is also required so that ``uv run mypy .`` in CI -- which
122+
# traverses every path under the current dir -- doesn't rediscover the same
123+
# files under their ``docs._ext.`` prefix and error "Source file found twice".
124+
mypy_path = ["docs/_ext"]
125+
exclude = ["^docs/"]
118126

119127
[[tool.mypy.overrides]]
120128
module = ["docutils", "docutils.*"]

0 commit comments

Comments
 (0)