ByteString, specifying length for any bytes-like variable
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 1.8k
- Forks
- 302
- Ø Merge
- 23 Std.
- Gemergte PRs (30 T.)
- 8
Beschreibung
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,bytearrayandmemoryview - 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?
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Es wird keine Datei, kein Test und kein Einstiegspunkt genannt. Beginne damit, das bestehende Typisierungsverhalten von ByteString und verwandte Diskussionen zur Typisierung zu prüfen, und ermittle anschließend, ob sich bytes-ähnliche Typen, feste oder begrenzte Längen und Schreibbarkeit ohne mypy-Fehler darstellen lassen. Als abgeschlossen gilt die Aufgabe, wenn ein abgestimmtes Annotierungsdesign und dokumentiertes Verhalten der Typprüfung vorliegen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- developer-experience
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100