Add option to functools.update_wrapper()/@wraps to copy the coroutine flag
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 77.2k
- Forks
- 35.9k
- Métriques de merge des PR
- Métriques de PR en attente
Description
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
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par lire functools.update_wrapper() et @wraps, puis consultez les discussions précédentes dans #100317 et python/cpython#122088 au sujet de la copie de l’état de coroutine. La tâche serait terminée lorsqu’un comportement optionnel de l’API aura été convenu, avec une implémentation, des tests et une documentation correspondants.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- backend-api-design
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 38/100