Skip to content

feat(storage): refactor sync and async methods - #1364

Merged
o-santi merged 46 commits into
v3from
storage/sync-async-refactor
Feb 10, 2026
Merged

feat(storage): refactor sync and async methods#1364
o-santi merged 46 commits into
v3from
storage/sync-async-refactor

Conversation

@o-santi

@o-santi o-santi commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Rewrite storage to also use supabase_utils.http, removing the need for _sync and _async.

Breaking changes

This PR contains some breaking changes.

  1. Most options TypedDict have been inlined as method kwargs. This makes the logic for handling them easier, and also makes the type checkers happier. The ones that were 2 levels deep (eg. TransformOptions) were transformed into pydantic.dataclasses.dataclass objects, so that we have type validation on these inputs.
  2. All returned objects now are validated, most of them through BaseModels.
  3. I've removed most of the Mixin classes, for there isn't a clear reason for not just inlining them in the original class, and this makes the codebase easier to read overall.
  4. Some functions did return a path field, which was actually just one of the original arguments to said function. I just removed those, for it is confusing, and it may seem to the user that the returned path is somehow different/special.
  5. mypy is now strict! No more Any.
  6. Moved to python >=3.10 only, removed all Optional, Unions and so on.

this way, we only need to write the whole client once, and we can
derive both IO implementations from a single source of truth, reducing
the amount of code needed for each package in half.
lets start already very strict, so that we don't have to strict it up later.
this is because, inside the `http_endpoint` class definition, we have
the equivalent of the following assignment:
```
s : ServerEndpoint[Success, Failure]
a : ServerEndpoint[Awaitable[Success] | Success, Failure] = s
```
as such, we need to make `Awaitable[Success] | Success` a subtype of
`Success`, which means that it needs to be covariant!
I'm currently experimenting with other type checkers, and seeing if
they agree on the type stuff done in http. pyrefly accepts all of it,
but complains about the TypeAlias annotation in the json part. it isnt
necessary so I just removed it.
… TypedDicts

this is a partial commit, and is not fully working yet.
this ideally makes it more general, and lets endpoints specify how
they want to send information through in multiple ways. this is needed
to handle the case where we send bytes through edge functions directly

addionally, we're not using json.loads anymore, and relying solely on
pydantic's `to_json` machinery, which should be miles faster (written
in rust!)
the type ignore is useful for python < 3.11, but mypy doesnt know that
rename classes with `endpoint` in their name. given that this is a
client, and not a server, these might not make sense

the initial idea was that these were supposed to hit a 'server
endpoint', but I think that the name is confusing after trying to use
it elsewhere

i've also split the one request class into multiple, because it makes
more sense in the context of the other packages
@coderabbitai

coderabbitai Bot commented Feb 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch storage/sync-async-refactor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@o-santi
o-santi force-pushed the storage/sync-async-refactor branch from 09438c4 to 9d5a31f Compare February 2, 2026 19:25
@o-santi
o-santi changed the base branch from v3 to sync-async-refactor February 2, 2026 19:32
@o-santi
o-santi changed the base branch from sync-async-refactor to v3 February 2, 2026 19:32
@o-santi o-santi mentioned this pull request Feb 3, 2026
@o-santi
o-santi merged commit dee0f62 into v3 Feb 10, 2026
34 checks passed
@o-santi
o-santi deleted the storage/sync-async-refactor branch February 10, 2026 16:47
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