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

feat: introduce typeddicts for request objects #4113

Merged
merged 34 commits into from
Jul 29, 2024
Merged

Conversation

armandobelardo
Copy link
Contributor

@armandobelardo armandobelardo commented Jul 24, 2024

This PR makes it so that we create TypedDict clones for any object we have, e.g. aliases of objects, objects, unions and undisc unions. These clones are stored in a requests module alongside the other types, and are used in the method signatures for our SDK methods.

Generally the architecture is:

  • typeddict.py - general construction and utilities for understanding if something can be a typeddict, snippets, etc.
  • Whenever we get a Reference now, you can specify if that reference is used in a request -- if so, we then check if the SDK is using TypedDicts and handle retrieving the appropriate reference for the type (e.g. if it can be a typeddict, and you're in a request, and have typeddicts enabled, then we get the reference for the type in the requests module)
    • This happens through the plumbing of as_request and use_typeddict_requests
  • Constructing TypedDicts side-saddles existing Pydantic model creation, see object_generator.py, etc. -- we effectively gather a list of fields and then pass that to the pydantic_model.py, as well as typeddict.py such that both model forms get created
  • Snippets for TypedDicts side-saddle the existing snippet infra, similar to model construction, see ObjectSnippetGenerator in object_generator.py as an example

Seed run: #4128

@armandobelardo armandobelardo marked this pull request as ready for review July 29, 2024 17:13
@armandobelardo armandobelardo changed the title wip: introduce typeddicts for request objects feat: introduce typeddicts for request objects Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants