Add better typing to support variable OrderStatus objects #128
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.
What I'm changing
A existing problem with the typing for various methods is that an implementer could not create their own implementation of OrderStatus and have additional properties in it be serialized in server responses. This is due to fastapi's use of type annotations for determining what serializer to use when returning an object from an endpoint. As defined, any object returned as the status (either with an Order or from the Order statuses endpoint) will be serialized as an Order Status, so any additional provider-specific attributes are not included. However, by adding the correct generic typing, a provider can redefine these endpoints so their own custom OrderStatus class will be serialized correctly.
How I did it
Checklist
./scripts/run-tests.shuv run pre-commit run --all-files