Skip to content

Add __bytes__ to GetBlobResult#53

Open
scotttrinh wants to merge 1 commit intomainfrom
dunder-bytes
Open

Add __bytes__ to GetBlobResult#53
scotttrinh wants to merge 1 commit intomainfrom
dunder-bytes

Conversation

@scotttrinh
Copy link
Collaborator

The get() method recently changed from returning raw bytes to returning a GetBlobResult envelope. Adding __bytes__ lets consumers use bytes(result) idiomatically instead of reaching into the .content property, easing the migration.

The get() method recently changed from returning raw bytes to
returning a GetBlobResult envelope. Adding __bytes__ lets
consumers use bytes(result) idiomatically instead of reaching
into the .content property, easing the migration.
@scotttrinh scotttrinh requested review from 1st1, Copilot and vvo February 23, 2026 21:30
@vercel
Copy link

vercel bot commented Feb 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vercel-py Ready Ready Preview Feb 23, 2026 9:30pm

Request Review

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a __bytes__ implementation to GetBlobResult so callers can use bytes(result) as an ergonomic migration path now that get() returns an envelope object instead of raw bytes.

Changes:

  • Add GetBlobResult.__bytes__() returning content.
  • Update the blob storage example to use bytes(result) instead of result.content.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/vercel/blob/types.py Introduces __bytes__ on GetBlobResult to support bytes(result) conversions.
examples/blob_storage.py Demonstrates the new bytes(result) usage in the get() example output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +71 to +72
def __bytes__(self) -> bytes:
return self.content
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__bytes__ is a new public behavior on GetBlobResult, but there’s no unit test asserting bytes(result) returns the response content (and works for both 200 and 304 cases). Adding a small assertion in the existing _build_get_result tests would prevent regressions and validate the intended migration path.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Examples are run as tests, so this is covered.

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

Successfully merging this pull request may close these issues.

2 participants