Skip to content

type definitions became hidden #855

Closed

Description

@dmig-alarstudios

httpx type definitions became unavailable starting with release 0.12.

I'm talking about HeaderTypes, URLTypes, QueryParamTypes, CookieTypes which can be useful.

Activity

  1. lovelydinosaur commented on Mar 9, 2020

    @lovelydinosaur
    Member

    Correct. We use those for internal use only, and we're not exposing them as part of the public API.

  2. dmig-alarstudios commented on Mar 13, 2020

    @dmig-alarstudios
    Author

    Hiding these types is not correct -- there should be a way to declare types when subclassing AsyncClient

  3. florimondmanca commented on Mar 13, 2020

    @florimondmanca
    Contributor

    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.

  4. lovelydinosaur commented on Mar 13, 2020

    @lovelydinosaur
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    user-experienceEnsuring that users have a good experience using the library

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions