Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use less private imports on the testclient module #2709

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Kludex
Copy link
Member

@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
Member 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
Member Author

Kludex commented Oct 14, 2024

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

@Kludex
Copy link
Member Author

Kludex commented Oct 18, 2024

@zanieb @tomchristie was this discussed in the meeting?

@tomchristie
Copy link
Member

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
Member Author

Kludex commented Oct 24, 2024

What is expected from Starlette?

@tomchristie
Copy link
Member

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
Member

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
Member 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
Member 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
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