python / python/mypy

enigmatic "name already defined" error

Aperta
#7,206 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug priority-1-normal
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia eseguendo le quattro riproduzioni inline con la versione di mypy indicata, usando test.py per la funzione importata. Confronta le diagnostiche per ogni ordine di importazione e ridefinizione. Il lavoro è completato quando il comportamento è coerente con l’aspettativa del report secondo cui tutti e quattro i casi emettono l’errore duplicate-definition.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
devtools
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.