mcap 1.4.0: mypy fails with: Source file found twice under different module names: "mcap" and "mcap.__init__"
bug
**Description**
The `mypy` Python library recently shipped version 1.4.0, which was picked up by our automatic version dependency bump. Among other things, it [changes](https://github.com/foxglove/mcap/commit/bc87ac1de776e6d65ea4b251630b0df27e9bc26a#diff-42b916e07a048464827bec8c38f5075d02d2038df6c0ab09b9dbc3bbf6579141) an import statement in `mcap/writer.py` from
```python
from mcap import __version__
```
to:
```python
from .__init__ import __version__
```
Because mcap and mcap_ros1/mcap_ros2 ship py.typed, mypy follows into them; once a mypy run over our repo holds both `import mcap` (-> module `mcap`) and a path reaching `mcap.writer` (-> module `mcap.__init__`), mypy sees one file under two module names and aborts.
- Version: 1.4.0 (`mcap` Python library)
- Platform: MacOS
**Steps To Reproduce**
Minimal repro:
```shell
# One-time: scratch venv with just the relevant packages
python3 -m venv /tmp/mypy-mcap-env
/tmp/mypy-mcap-env/bin/pip install "mypy==1.15" "mcap==1.4.0"
# Repro file
printf 'import mcap\nfrom mcap.writer import Writer\n' > /tmp/mcap_repro.py
# Repro mypy invocation
/tmp/mypy-mcap-env/bin/mypy --follow-imports=normal /tmp/mcap_repro.py
.../site-packages/mcap/__init__.py: error: Source file found twice under different module names: "mcap" and "mcap.__init__"
Found 1 error in 1 file (errors prevented further checking)
```
**Expected Behavior**
`mypy` succeeds.
关闭于 2026-06-24 1 条评论