TypeErrors against public interfaces.
See original GitHub issuePartly prompted by this comment.
I think we should probably be a bit strict about enforcing types passed to our public interfaces. It’d be nice to raise loud clear errors, rather than failing with some arbitrary AttributeError in the middle of the codebase if a user passes something completely invalid to the interface. This would be stricter than what most Python libraries do, but I think it might be a good trade-off for us, to have a very strict and clearly demarked API.
That’d be easy enough to do since there’s not too many points we’d need to enforce.
The big obvious one would be checking everything in AsyncClient.request()
, which most of the rest of the public API calls into.
The would be some other bits & pieces to check too eg. Enforce that streaming data iterates through bytes/str, and not any other types. Enforce that dispatchers really do return a response type. Type checking on the various models that we expose.
Perhaps I’m being over-zelaous here? Any thoughts?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (6 by maintainers)
Top GitHub Comments
I’d rather be strict about what we accept, then we don’t have to handle odd-ball cases down the road as a point of “backwards-compatibility” because it used to work but not on purpose.
We might want to have this at some point, but closing it as out-of-scope for now.