Add option to functools.update_wrapper()/@wraps to copy the coroutine flag
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Feature or enhancement
Proposal:
This came up during python/cpython#122088, where it was noted that @deprecated drops the coroutine flag of a function. @deprecated uses @wraps/update_wrapper internally. This was previously discussed in #100317, where it was suggested that the flag should be copied automatically. It was ultimately decided by @gvanrossum that this is dangerous, since wrappers might decide to convert from/to coroutines.
I propose to add a flag to update_wrapper() and @wraps to optionally copy the status:
- It's more convenient to use than using the boilerplate code mentioned in the previous issue. Especially since I would assume that most wrappers want to copy this status.
- Probably more important: This makes this problem and its solution discoverable. As the
@deprecatedexample shows, most people probably don't think about this issue when creating a wrapper. By adding a flag to the API and the documentation, this problem will be mentioned and can be discovered by users of@wraps, either while reading the documentation, or when the IDE shows the availability of the flag.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
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
Empieza leyendo functools.update_wrapper() y @wraps; después revisa las discusiones anteriores en #100317 y python/cpython#122088 sobre la copia del estado de corrutina. La tarea estaría terminada cuando exista un comportamiento opcional de la API acordado, junto con una implementación, pruebas y documentación coherentes.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend-api-design
- 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