Skip to content

Add tests/__init__.py to fix mypy duplicate-module error - #96

Merged
randileeharper merged 1 commit into
mainfrom
fix/mypy-conftest-duplicate-modules
Jun 28, 2026
Merged

Add tests/__init__.py to fix mypy duplicate-module error#96
randileeharper merged 1 commit into
mainfrom
fix/mypy-conftest-duplicate-modules

Conversation

@randileeharper

Copy link
Copy Markdown
Owner

Summary

Fixes #82.

Running mypy vesper tests failed immediately with:

tests/conftest.py: error: Source file found twice under different module names: "conftest" and "tests.conftest"

because tests/ had no __init__.py, so mypy resolved conftest under two module names. The test suite already imports from tests.conftest import ... (in test_historian.py and test_mcp.py), so treating tests as a package is the intended design — this makes it explicit, which is exactly the "simplest" option mypy itself recommends and the issue lists first.

This change was already in effect for runtime/pytest; it only corrects mypy's module resolution. After this change mypy no longer aborts with the duplicate-module error, and the production code (mypy vesper) remains fully clean (0 issues).

Follow-up

Fixing the duplicate-module error unmasked 51 pre-existing type errors in the test suite that mypy previously never reached (it aborted at the duplicate-module error before checking the test files). These are tracked separately in a follow-up issue and are out of scope here — this PR fixes the reported bug only.

Verification

Exact commands run (per AGENTS.md, using the project virtualenv):

.venv/bin/python -m mypy vesper tests      # duplicate-module error gone; vesper clean (51 pre-existing test errors remain, tracked separately)
.venv/bin/python -m mypy vesper           # Success: no issues found in 37 source files
.venv/bin/python -m pytest -q            # 251 passed
.venv/bin/python -m ruff check vesper tests   # All checks passed!
.venv/bin/python -m compileall -q vesper tests

Closes #82.

Running `mypy vesper tests` failed immediately with:

  tests/conftest.py: error: Source file found twice under different module
  names: "conftest" and "tests.conftest"

because `tests/` had no `__init__.py`, so mypy saw conftest under two module
names. The test suite already imports `from tests.conftest import ...`
(test_historian.py, test_mcp.py), so treating `tests` as a package is the
intended design -- this makes it explicit, as mypy itself recommends.

Note: this change was already in effect for runtime/pytest. It only corrects
the mypy module resolution. Fixing the resulting unmasked test-suite type
errors is tracked separately.

Closes #82
@randileeharper
randileeharper merged commit 2fd37b4 into main Jun 28, 2026
1 check passed
@randileeharper
randileeharper deleted the fix/mypy-conftest-duplicate-modules branch June 28, 2026 16:10
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.

mypy invocation fails: tests/conftest found under two module names

1 participant