enigmatic "name already defined" error
まだ誰も着手していません。
評価
調査の方向性
まず、報告された mypy のバージョンで 4 つのインライン再現を実行し、インポートされる関数には test.py を使用します。各インポート順序と再定義順序について診断結果を比較します。4 つすべてのケースで duplicate-definition エラーが出力されるというレポートの期待どおりの動作になれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 54
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/mypy のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
bug topic-configuration topic-error-reporting
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
zostera/django-bootstrap4#894 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
use-agent-os/agent-os#3276 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
NousResearch/hermes-agent#117848 ·