ByteString, specifying length for any bytes-like variable
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 302
- Avg merge
- 23h
- Merged PRs (30d)
- 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,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?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file, test, or entry point is named. Start by reviewing the existing ByteString typing behavior and related typing discussions, then determine whether bytes-like types, fixed or bounded lengths, and writability can be represented without mypy errors. Done would require an agreed annotation design and documented type-checking behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100