local stubs folder makes mypy think an unrelated `module.__init__` duplicates `module`

オープン
#18,775 コメント 0 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
devtools

調査の方向性

まず reproduction.zip を展開し、含まれている設定とローカルスタブを使って python3.13 -m mypy . を実行します。my_package._dynamicmy_package._dynamic.__init__ の両方を報告するモジュールパスの処理を追跡します。重複モジュールエラーを回避しつつ、スタブパッケージをインポート不能にしなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

bug

Bug Report

Having a local stubs folder makes mypy think an unrelated module.__init__ duplicates module.

Deleting the __init__.pyi in the local stubs solves the issue, but will cause many more issues where mypy thinks the package can't be imported.

This happens with or without explicit_package_bases.

To Reproduce

MRE: reproduction.zip

Expected Behavior

No error or some way to work around this issue

Actual Behavior

my_package\_dynamic\__init__.py: error: Source file found twice under different module names: "my_package._dynamic" and "my_package._dynamic.__init__"
my_package\_dynamic\__init__.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
my_package\_dynamic\__init__.py: note: Common resolutions include: a) adding `__init__.py` somewhere, b) using `--explicit-package-bases` or adjusting MYPYPATH
Found 1 error in 1 file (errors prevented further checking)

Your Environment

  • Mypy version used: mypy 1.15.0 (compiled: yes)
  • Mypy command-line flags: python3.13 -m mypy .
  • Mypy configuration options from mypy.ini (and other config files): (see MRE)
  • Python version used: Python 3.13.0
主要言語
Python
スター
20.6k
フォーク
3.3k
平均マージ
1日 18時間
マージ済み PR(30日)
54

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

python/mypy のほかの issue

python/mypy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。