Skip to content

mypy reads Toad's declared source roots (src, tools); pairs with Core P883 - #1314

Merged
trissim merged 1 commit into
mainfrom
config/mypy-source-roots
Oct 29, 2026
Merged

trissim merged 1 commit into
mainfrom
config/mypy-source-roots

Conversation

@trissim

@trissim trissim commented Oct 29, 2026

Copy link
Copy Markdown

One line of config: mypy reads Toad's declared source roots, src and tools. It is paired with Core P883. It unblocks Core's debt-src, which currently crashes on every Core PR before comparing anything:

ClientTypeErrors could not check batrachian-toad at 20eac8baf…: tools/performance: error:
Source file found twice under different module names: "tools.performance" and "performance"

(agent-comms run 40800748028, job 123208052787)

 [tool.mypy]
 follow_untyped_imports = true
+mypy_path = ["src", "tools"]

Why this config is the one the checker reads

Core tools/debt_ratchet.py, ClientTypeErrors.checked:

  • it runs python -m mypy with cwd=client.checkout, this repository;
  • TypeErrors.mypy passes --explicit-package-bases and no --config-file;
  • it sets MYPYPATH to Core's archived src plus this checkout's src.

So mypy discovers its config in this checkout. Toad main has pyproject.toml and no mypy.ini, .mypy.ini or setup.cfg, so [tool.mypy] here is the config it selects.

Why it removes the duplicate name

From mypy's find_sources.py:

  • the explicit package bases are MYPYPATH + options.mypy_path + [cwd] (get_explicit_package_bases, line 93);
  • a source file takes the first base met while crawling up from its directory (_crawl_up_helper, line 186).

With only cwd as a base, tools/performance/*.py (no __init__.py) is named tools.performance.*. Meanwhile tools/acceptance.py:34-36 puts its own directory on sys.path and imports performance.*. With tools as a base, the crawl stops at tools, so the package gets the one name its importer uses. src is listed because it is the other declared root; Core's MYPYPATH already names it.

Scope

🤖 Generated with Claude Code

https://claude.ai/code/session_01RnH6dS2Kmg1WxNnAc78YHA

Core's ClientTypeErrors runs mypy from this checkout with
--explicit-package-bases and no --config-file, so this pyproject's
[tool.mypy] is the config it reads (no mypy.ini, .mypy.ini or setup.cfg
here). Its package bases are MYPYPATH, then mypy_path, then cwd
(mypy find_sources.py:93), and a file takes the first base met crawling up
(:186). With only cwd, tools/performance/*.py is "tools.performance.*" while
tools/acceptance.py:34-36 imports it as "performance.*", and mypy refuses:
"Source file found twice under different module names". Naming tools as a
root gives it the one name its importer uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dS2Kmg1WxNnAc78YHA
Copilot AI balanced review requested due to automatic review settings October 29, 2026 01:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@trissim
trissim merged commit 5e157f8 into main Oct 29, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants