enigmatic "name already defined" error
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die vier Inline-Reproduktionen mit der gemeldeten mypy-Version auszuführen, wobei du test.py für die importierte Funktion verwendest. Vergleiche die Diagnosen für jede Reihenfolge von Import und Neudefinition. Erledigt ist dies, wenn das Verhalten der Erwartung des Reports entspricht, dass alle vier Fälle den duplicate-definition-Fehler ausgeben.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100