You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I sort of agree with @dmig-alarstudios's point that assuming we're to encourage users to subclass from AsyncClient (which we'd sort of do e.g. for UDS or any third-party extra feature support), and we want to provide a good typing experience, then it's inevitable that some of our types should end up as public API. Not clear to me which ones we'd like to expose exactly, but eg TimeoutTypes would be a good candidate already.
So, while I get that the typical thoughtline here would run to "least amount of keyboard typing possible" I actually think that exposing the type annotations that we're using obscures the actual typing, rather than benefiting the developer.
If anything, this issue makes me keener to (now or eventually) reassess #789, and consider not using type annotation shorthands in our codebase at all.
Re-using the annotations we have in our codebase may not actually be a typically correct thing for end-user codebases to do in any case, they'll typically actually want to expose a more constrained subset (ie. "httpx would let us user types X, Y, or Z here, but we're actually using type X, so type it to that")
I get that'll be counter to most folks initial expectations, but my feeling is that it'd help enforce more explicit typing, rather obscuring it.
Activity
lovelydinosaur commentedon Mar 9, 2020
Correct. We use those for internal use only, and we're not exposing them as part of the public API.
dmig-alarstudios commentedon Mar 13, 2020
Hiding these types is not correct -- there should be a way to declare types when subclassing AsyncClient
florimondmanca commentedon Mar 13, 2020
I sort of agree with @dmig-alarstudios's point that assuming we're to encourage users to subclass from
AsyncClient(which we'd sort of do e.g. for UDS or any third-party extra feature support), and we want to provide a good typing experience, then it's inevitable that some of our types should end up as public API. Not clear to me which ones we'd like to expose exactly, but egTimeoutTypeswould be a good candidate already.lovelydinosaur commentedon Mar 13, 2020
So, while I get that the typical thoughtline here would run to "least amount of keyboard typing possible" I actually think that exposing the type annotations that we're using obscures the actual typing, rather than benefiting the developer.
If anything, this issue makes me keener to (now or eventually) reassess #789, and consider not using type annotation shorthands in our codebase at all.
Re-using the annotations we have in our codebase may not actually be a typically correct thing for end-user codebases to do in any case, they'll typically actually want to expose a more constrained subset (ie. "httpx would let us user types X, Y, or Z here, but we're actually using type X, so type it to that")
I get that'll be counter to most folks initial expectations, but my feeling is that it'd help enforce more explicit typing, rather obscuring it.