Enum field 'name' conflics with instance attribute 'name'

Aperta
#4,654 9 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

No source file or test is named. Start by reproducing the reported error with the shown stub and Enum definition, then inspect how mypy handles Enum members named name and determine the expected behavior for autogenerated stubs.

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

Descrizione

bug false-positive needs discussion priority-1-normal topic-enum

This is my stub file which I can control.

    class Type(enum.Enum):
        EMPTY = ...
        name = ...       <<<<<<<<
        datasetConfig = ...
        value: int

error: Incompatible types in assignment (expression has type "ellipsis", base class "Enum" defined the type as "str")

The enum is defined as

class Type(enum.Enum):
    EMPTY = 0
    name = 1
    datasetConfig = 2

This is autogenerated code and I don't have control over the enum field names, is there some way for me to have a working stub for this code?

Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Merge medio
1g 18h
PR unite (30g)
54

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.

Altre issue di python/mypy

Tutte le issue di python/mypy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.