-
Notifications
You must be signed in to change notification settings - Fork 159
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
Conversation
This file contains 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
dsinghvi
reviewed
Jul 26, 2024
...rators/python/src/fern_python/generators/sdk/client_generator/endpoint_function_generator.py
Show resolved
Hide resolved
dsinghvi
reviewed
Jul 26, 2024
...rators/python/src/fern_python/generators/sdk/client_generator/endpoint_function_generator.py
Show resolved
Hide resolved
dsinghvi
reviewed
Jul 26, 2024
generators/python/src/fern_python/generators/sdk/context/sdk_generator_context.py
Show resolved
Hide resolved
dsinghvi
reviewed
Jul 26, 2024
...rn_python/generators/sdk/declaration_referencers/environments_enum_declaration_referencer.py
Show resolved
Hide resolved
armandobelardo
changed the title
wip: introduce typeddicts for request objects
feat: introduce typeddicts for request objects
Jul 29, 2024
dsinghvi
approved these changes
Jul 29, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.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 therequests
module)as_request
anduse_typeddict_requests
object_generator.py
, etc. -- we effectively gather a list of fields and then pass that to thepydantic_model.py
, as well astypeddict.py
such that both model forms get createdObjectSnippetGenerator
inobject_generator.py
as an exampleSeed run: #4128