You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After #22, tests throughout are experiencing this error:
______________________________________________________________________ [mypy] __main__.py _______________________________________________________________________
__main__.py: error: Duplicate module named "__main__" (also at "__init__.py")
__main__.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
__main__.py: note: Common resolutions include:
__main__.py: note: a) using `--exclude` to avoid checking one of them,
__main__.py: note: b) adding `__init__.py` somewhere,
__main__.py: note: c) using `--explicit-package-bases` or adjusting `MYPYPATH`
Mypy provides its behavior through optimized, generated C files, so when running --editable, the monkey patching works as intended, but when run from a binary install (or other optimized build), the monkey patch never has any effect. Moreover, it seems not to be possible to disable the use of the compiled sources easily.
It looks like it may be possible to delete the mypy extension sources by looking at importlib.machinery.EXTENSION_SUFFIXES and deleting all such files in the mypy install (which is temporary anyway).
Or maybe we should switch to pyrefly or ty for type checking (if either has a pytest plugin).
Activity
jaraco commentedon May 25, 2026
Aha, so the issue only manifests now when
coherent.testis installed under pip-run and thecoherent.testentry point.jaraco commentedon May 25, 2026
Duh. That's because the mypy.ini isn't generated without that change.
After adding that manually, I'm able to replicate the issue in a venv with
-e .[test]installed usingpy -m pytest.jaraco commentedon May 25, 2026
Aha. I figured out the issue.
Mypy provides its behavior through optimized, generated C files, so when running
--editable, the monkey patching works as intended, but when run from a binary install (or other optimized build), the monkey patch never has any effect. Moreover, it seems not to be possible to disable the use of the compiled sources easily.It looks like it may be possible to delete the mypy extension sources by looking at
importlib.machinery.EXTENSION_SUFFIXESand deleting all such files in the mypy install (which is temporary anyway).Or maybe we should switch to pyrefly or ty for type checking (if either has a pytest plugin).
Disable pytest-mypy for now until a solution can be devised.