Type-hint ApiParser using TypedDict #709
Closed
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.
Hi, I'm looking to build on this code and I would personally find type-hints helpful. Feel free to reject if you don't want them. In that case, I'll remove from my own branch before any future PR.
The problem to be solved: when consuming the library, a developer must manually track the expected keys to avoid KeyError. With type hints, the IDE can auto-complete the correct keys and hint the values.
As you probably know, TypedDict is a check-time construct and has no runtime effect.
My personal preference is to use pydantic, as the syntax is cleaner, but it would add a dependency and has a runtime effect. If you'd like me to resubmit using pydantic, let me know, and I'll update and test.