multiformats / multiformats/py-multibase
`Encoder` class lacks a `code` property exposing the prefix byte
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 25
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
The Encoder class stores the prefix code internally as self._codec.code but doesn't expose it as a public property. Users who need the prefix byte must access the private _codec attribute or call get_encoding_info().
Problem
enc = Encoder("base16")
enc.encoding # "base16" ✅ — name is public
enc.code # ❌ AttributeError — prefix byte not exposed
enc._codec.code # b"f" — works but accesses private attribute
Go's Encoder exposes the encoding code:
func (p Encoder) Encoding() Encoding {
return p.enc // Returns the Encoding constant (e.g., Base16 = 'f')
}
Proposed Solution
Add a code property to the Encoder class:
class Encoder:
@property
def code(self) -> bytes:
"""The multibase prefix byte for this encoding."""
return self._codec.code
Add tests and update __init__.py exports if needed.
Related
- Go equivalent:
Encoder.Encoding()method in go-multibaseencoder.go
Contributor guide
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
Start by locating the Python Encoder class and its existing tests, then inspect how the internal _codec.code value is exposed. Add the public code property described in the issue, update init.py exports only if needed, and add tests confirming the returned prefix byte for an encoding such as base16.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 76/100