New enum features in Python 3.11
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza revisando el manejo existente de los enums de Python por parte de mypy y la documentación de enums de Python 3.11. Usa los ejemplos del issue para enum.verify y enum.member/nonmember para determinar el comportamiento esperado y, después, verifica que las funcionalidades no compatibles enumeradas se gestionen de forma coherente, teniendo en cuenta los issues vinculados por separado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- devtools
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100