Skip to content
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

Add BytesIO loader #270

Closed
lubaskinc0de opened this issue Apr 6, 2024 · 2 comments
Closed

Add BytesIO loader #270

lubaskinc0de opened this issue Apr 6, 2024 · 2 comments

Comments

@lubaskinc0de
Copy link
Contributor

lubaskinc0de commented Apr 6, 2024

we can add a io.BytesIO loader like any existing bytes-like loader

from adaptix import Retort, loader, P


@dataclass
class Book:
    image: BytesIO


data = {
    "image": b64encode(bytes(b"hello"))
}

retort = Retort(
    recipe=[
        loader(P[Book].image, lambda x: b64decode(x))
    ]
)

book = retort.load(data, Book)
print(book)
@lubaskinc0de
Copy link
Contributor Author

lubaskinc0de commented Apr 6, 2024

i'm work on it

@lubaskinc0de
Copy link
Contributor Author

we also can add provider for IO[bytes]

zhPavel added a commit that referenced this issue Apr 6, 2024
BytesIOBase64Provider and IOBytesBase64Provider (#270)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant