enigmatic "name already defined" error
オープン
まだ誰も着手していません。
bug
priority-1-normal
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Please provide more information to help us understand the issue:
- Are you reporting a bug, or opening a feature request?
Bug.
- Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
There are four pieces of code:
def func(x: int) -> int:
return x + 1
def func(x):
return x
def func(x):
return x
def func(x: int) -> int:
return x + 1
from test import func
def func(x: int) -> int:
return x + 1
def func(x: int) -> int:
return x + 1
from test import func
Whenever test is used as a module, test.py contains
def func(x):
return x
- What is the actual behavior/output?
The first three examples emits "Name 'func' already defined" error, but not the last
- What is the behavior/output you expect?
All four should emit this error.
- What are the versions of mypy and Python you are using?
mypy 0.720+dev.dc6da54f50d5443fe46308046719043eba03c84d (master at the time of bug report)
Python 3.7.3
- What are the mypy flags you are using? (For example --strict-optional)
None.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、報告された mypy のバージョンで 4 つのインライン再現を実行し、インポートされる関数には test.py を使用します。各インポート順序と再定義順序について診断結果を比較します。4 つすべてのケースで duplicate-definition エラーが出力されるというレポートの期待どおりの動作になれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100