python / python/typing

ByteString, specifying length for any bytes-like variable

Ouverte
#997 4 commentaires 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

topic: feature
Langage dominant
Python
Étoiles
1.8k
Forks
302
Merge moyen
23 h
PR mergées (30 j)
8

Description

This request is a combination of two additions to ByteString that apparently are not supported yet, or at least I could find no discussion of them.

  • Support any bytes-like buffers, not only bytes, bytearray and memoryview
  • Allow specifying the length of the buffer expected (in my case it usually must be exactly 32 bytes)

Ideally, Python typing would allow specifying bytes-like of (a) any length, (b) fixed length or (c) min and/or max length. Potentially also separately specifying if a writable buffer is expected.

While I don't expect for mypy to be able to check for all of that, it would at least be nice to include such information in the annotations for documentation purposes, avoiding the use of docstrings for parameter definitions where names and types are descriptive enough. Is there any way to do this without causing mypy errors, considering that I would rather have no type checking but documentative annotations than what the current implementation can do?

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Aucun fichier, test ou point d’entrée n’est indiqué. Commencez par examiner le comportement de typage existant de ByteString et les discussions connexes sur le typage, puis déterminez si les types similaires à bytes, les longueurs fixes ou bornées et la possibilité d’écriture peuvent être représentés sans erreurs de mypy. Le travail sera considéré comme terminé lorsqu’une conception d’annotations approuvée et le comportement documenté de la vérification de types seront disponibles.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
developer-experience
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.