Skip to content

Use less private imports on the testclient module#2709

Closed
Kludex wants to merge 3 commits intomasterfrom
less-private-imports-on-testclient
Closed

Use less private imports on the testclient module#2709
Kludex wants to merge 3 commits intomasterfrom
less-private-imports-on-testclient

Conversation

@Kludex
Copy link
Copy Markdown
Owner

@Kludex Kludex commented Sep 29, 2024

Comment on lines +43 to +55
Auth: TypeAlias = "httpx.Auth | tuple[str | bytes, str | bytes]"
QueryParams: TypeAlias = "httpx.QueryParams | typing.Mapping[str, str] | None"
Cookies: TypeAlias = "httpx.Cookies | CookieJar | dict[str, str] | list[tuple[str, str]] | None"
URL: TypeAlias = "httpx.URL | str"
Timeout: TypeAlias = "float | httpx.Timeout | tuple[float | None, float | None, float | None, float | None] | None"
Headers = typing.Union[
httpx.Headers,
typing.Mapping[bytes, bytes],
typing.Mapping[str, str],
typing.Sequence[typing.Tuple[bytes, bytes]],
typing.Sequence[typing.Tuple[str, str]],
None,
]
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pretty much have to do what httpx is doing on the _client module because I think we want to support the type possibilities that are there...

@Kludex
Copy link
Copy Markdown
Owner Author

Kludex commented Oct 14, 2024

@tomchristie Can we discuss/have a plan with this before httpx 1.0?

@Kludex
Copy link
Copy Markdown
Owner Author

Kludex commented Oct 18, 2024

@zanieb @tomchristie was this discussed in the meeting?

@lovelydinosaur
Copy link
Copy Markdown

To an extent... we did talk about stricter typing.
(Which would resolve this, by removing the need for type synonyms)

I'll see about spinning out a design discussion.

@Kludex
Copy link
Copy Markdown
Owner Author

Kludex commented Oct 24, 2024

What is expected from Starlette?

@lovelydinosaur
Copy link
Copy Markdown

What is expected from Starlette?

  • Don't access private implementation details.
  • Currently, pin to minor point releases, eg. >=0.27,<0.28.
  • Once we're at 1.0 you'l be able to pin to major point releases, eg. >=1.0,<2.0.

params: QueryParams | None = None,
headers: Headers | None = None,
cookies: Cookies | None = None,
auth: Auth | httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly...

UseClientDefault = type(httpx.USE_CLIENT_DEFAULT)

...

auth: Auth | UseClientDefault = USE_CLIENT_DEFAULT

(I don't much like this style and I'd enjoy cleaning it up, tho would that be sufficient for now?)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it works for the type checkers.. Does it?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't work.

@Kludex Kludex mentioned this pull request Nov 30, 2024
@Kludex Kludex closed this Feb 22, 2025
@Kludex
Copy link
Copy Markdown
Owner Author

Kludex commented Feb 22, 2025

I can't really subclass httpx.Client if the types are not exposed by httpx. 😢

@Kludex Kludex deleted the less-private-imports-on-testclient branch February 22, 2025 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Private imports from httpx.

2 participants