Skip to content

Conversation

@fsackur
Copy link
Contributor

@fsackur fsackur commented May 3, 2025

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.

@AdSchellevis
Copy link
Member

@fsackur I haven't really used them earlier, but don't mind adding them either. So far it hasn't drawn my attention much as these constructs suggests a strictness that doesn't exist runtime, which is less practical when building smaller scripts and not using an IDE, in which case it's easy to forget about updating the metadata as no visible signs will emerge.

For some reason using pydantic does sound a bit tempting as that would solve my primary concern, not sure about the dependencies, but for the docs rendering the FreeBSD part is a bit less relevant (I'm building these on osx anyway)

@fsackur
Copy link
Contributor Author

fsackur commented May 4, 2025

Duplicate of #713

Closes #713

@fsackur fsackur changed the title Type-hint ApiParser Type-hint ApiParser using TypedDict May 4, 2025
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