New enum features in Python 3.11
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
There's a ton of new enum features in Python 3.11 that mypy doesn't yet support:
-
enum.property -
enum.verify -
enum.(non)member -
ReprEnum -
StrEnum
enum.property is not yet supported:
- #12483
The new enum.verify decorator isn't supported: the following snippet will raise an exception at runtime on 3.11 due to not all values being unique, but it passes mypy:
from enum import Enum, verify, UNIQUE
@verify(UNIQUE)
class Color(Enum):
RED = 1
GREEN = 2
BLUE = 3
CRIMSON = 1
enum.member/enum.nonmember. The docs are a bit thin on these, but it looks like in the following enum, BAR is converted to become a member, but BAZ
is not:
from enum import Enum, nonmember
class Foo(Enum):
BAR = 1
BAZ = nonmember(2)
(These two can also be used as decorators)
ReprEnum: this doesn't need any special support by mypy, but the following mypy bug but means that it can't really be used idiomatically at the moment:
- #12787
StrEnum: I didn't think this required any special treatment from mypy, but there's a weird bug here in mypy's handling of StrEnum:
- #14688
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando la gestione esistente degli enum Python da parte di mypy e la documentazione degli enum di Python 3.11. Usa gli esempi dell'issue per enum.verify e enum.member/nonmember per determinare il comportamento previsto, quindi verifica che le funzionalità non supportate elencate siano gestite in modo coerente, tenendo conto delle issue collegate separatamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100