feat: add encoder_by_name factory function - #54
Open
sumanjeet0012 wants to merge 1 commit into
Open
Conversation
acul71
requested changes
Sep 7, 2026
acul71
left a comment
Contributor
There was a problem hiding this comment.
Review summary (maintainer)
Thanks for the clean encoder_by_name() addition — it matches issue #39 and go-multibase’s name/prefix factory pattern, keeps Encoder.__init__ backward compatible, and local/CI checks look good.
Blocker (must fix)
Missing newsfragment. Please add:
newsfragments/39.feature.rst
with a short user-facing ReST note (trailing newline required), e.g. that encoder_by_name() creates an Encoder from an encoding name or multibase prefix character.
Also please address
- Rebase onto
origin/master— branch is 6 commits behind (dry-run merge currently clean, but please sync). - Input hardening —
encoder_by_name(b"f")currently yieldsencoding == b"f"; non-strvalues likeNoneraiseAttributeError. Prefer requiringstror normalizing to the codec name. - Docs — README still only shows
Encoder('base64'); add a briefencoder_by_nameexample. - Tests (nice-to-have) — assert
.encode()via the factory, not only.encoding.
Notes
- No merge conflicts vs current
origin/master. - Informational: overlaps with PR #53 on
multibase.py/ tests. - Full review: local
downloads/AI-PR-REVIEWS/54/AI-PR-REVIEW-54-0.md.
Requesting changes until the newsfragment (and preferably rebase) is done.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #39
Description
This pull request adds an
encoder_by_name()factory function, which enables creating anEncoderfrom a single-character prefix as well as the standard name, bringing the python implementation into alignment with thego-multibasereference implementation.Changes
encoder_by_name()inmultibase/multibase.pywhich inspects the given string and resolves it if it matches either a name or a prefix.encoder_by_namefrom__init__.py.encoder_by_namedemonstrating successful construction from prefix, name, and base256emoji, as well as proper exception handling for unsupported/invalid strings.