-
-
Notifications
You must be signed in to change notification settings - Fork 3
add type stubs #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zzstoatzz
wants to merge
6
commits into
MarshalX:main
Choose a base branch
from
zzstoatzz:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add type stubs #56
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,6 @@ test.py | |
__pycache__ | ||
.benchmarks | ||
.pytest_cache | ||
|
||
# Build artifacts | ||
*.so |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from ._libipld import ( | ||
decode_cid, | ||
encode_cid, | ||
encode_dag_cbor, | ||
decode_car, | ||
decode_dag_cbor, | ||
decode_dag_cbor_multi, | ||
decode_multibase, | ||
encode_multibase, | ||
) | ||
|
||
__all__ = [ | ||
"decode_cid", | ||
"encode_cid", | ||
"encode_dag_cbor", | ||
"decode_car", | ||
"decode_dag_cbor", | ||
"decode_dag_cbor_multi", | ||
"decode_multibase", | ||
"encode_multibase", | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
from __future__ import annotations | ||
from typing import Any | ||
|
||
def decode_cid(data: str | bytes) -> dict[str, Any]: | ||
"""Decode a CID from either its string representation or raw bytes. | ||
|
||
Args: | ||
data: Either a CID string (e.g. 'bafy...') or raw CID bytes | ||
|
||
Returns: | ||
A dict containing: | ||
- version: int (0 or 1) | ||
- codec: int (e.g. 113 for DAG-CBOR) | ||
- hash: dict containing: | ||
- code: int (hash algorithm code) | ||
- size: int (hash size in bytes) | ||
- digest: bytes (hash digest) | ||
""" | ||
|
||
def encode_cid(data: str | bytes) -> str: | ||
"""Encode a CID to its string representation. | ||
|
||
Args: | ||
data: Either a CID string (will be returned as-is) or raw CID bytes | ||
|
||
Returns: | ||
A CID string (e.g. 'bafy...') | ||
""" | ||
|
||
def decode_car(data: bytes) -> tuple[dict[str, Any], dict[bytes, dict[str, Any]]]: | ||
"""Decode a CAR file. | ||
|
||
Args: | ||
data: Raw CAR file bytes | ||
|
||
Returns: | ||
A tuple containing: | ||
- header: dict (CAR header) | ||
- blocks: dict mapping CID bytes to block data | ||
""" | ||
|
||
def decode_dag_cbor(data: bytes) -> Any: | ||
"""Decode DAG-CBOR data to Python objects. | ||
|
||
Args: | ||
data: Raw DAG-CBOR bytes | ||
|
||
Returns: | ||
A Python object (dict, list, str, bytes, int, float, bool, or None) | ||
""" | ||
|
||
def decode_dag_cbor_multi(data: bytes) -> list[Any]: | ||
"""Decode multiple DAG-CBOR objects from bytes. | ||
|
||
Args: | ||
data: Raw DAG-CBOR bytes containing multiple objects | ||
|
||
Returns: | ||
A list of Python objects | ||
""" | ||
|
||
def encode_dag_cbor(data: Any) -> bytes: | ||
"""Encode Python objects to DAG-CBOR. | ||
|
||
Args: | ||
data: Any Python object that can be encoded to DAG-CBOR | ||
(dict, list, str, bytes, int, float, bool, or None) | ||
|
||
Returns: | ||
Raw DAG-CBOR bytes | ||
""" | ||
|
||
def decode_multibase(data: str) -> tuple[str, bytes]: | ||
"""Decode multibase-encoded data. | ||
|
||
Args: | ||
data: Multibase-encoded string (e.g. 'u' for base58btc) | ||
|
||
Returns: | ||
A tuple containing: | ||
- base: str (the base code, e.g. 'u') | ||
- data: bytes (the decoded data) | ||
""" | ||
|
||
def encode_multibase(code: str, data: Any) -> str: | ||
"""Encode data using multibase. | ||
|
||
Args: | ||
code: str (base code, e.g. 'u' for base58btc) | ||
data: Any Python object that can be converted to bytes | ||
(str, bytes, bytearray, or other objects that can be converted to bytes) | ||
|
||
Returns: | ||
Multibase-encoded string | ||
""" |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so
uv sync
gives you all you need formaturin develop --uv
notably,
dev
group members are not included in published metadata