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

Fix httpx private api usage #2534

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
38 changes: 18 additions & 20 deletions starlette/testclient.py
Expand Up @@ -472,10 +472,8 @@ def _portal_factory(self) -> typing.Generator[anyio.abc.BlockingPortal, None, No

def _choose_redirect_arg(
self, follow_redirects: bool | None, allow_redirects: bool | None
) -> bool | httpx._client.UseClientDefault:
redirect: bool | httpx._client.UseClientDefault = (
httpx._client.USE_CLIENT_DEFAULT
)
) -> bool | httpx._config.UseClientDefault:
redirect: bool | httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT
if allow_redirects is not None:
message = (
"The `allow_redirects` argument is deprecated. "
Expand Down Expand Up @@ -504,11 +502,11 @@ def request( # type: ignore[override]
headers: httpx._types.HeaderTypes | None = None,
cookies: httpx._types.CookieTypes | None = None,
auth: httpx._types.AuthTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
follow_redirects: bool | None = None,
allow_redirects: bool | None = None,
timeout: httpx._types.TimeoutTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
extensions: dict[str, typing.Any] | None = None,
) -> httpx.Response:
url = self._merge_url(url)
Expand Down Expand Up @@ -537,11 +535,11 @@ def get( # type: ignore[override]
headers: httpx._types.HeaderTypes | None = None,
cookies: httpx._types.CookieTypes | None = None,
auth: httpx._types.AuthTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
follow_redirects: bool | None = None,
allow_redirects: bool | None = None,
timeout: httpx._types.TimeoutTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
extensions: dict[str, typing.Any] | None = None,
) -> httpx.Response:
redirect = self._choose_redirect_arg(follow_redirects, allow_redirects)
Expand All @@ -564,11 +562,11 @@ def options( # type: ignore[override]
headers: httpx._types.HeaderTypes | None = None,
cookies: httpx._types.CookieTypes | None = None,
auth: httpx._types.AuthTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
follow_redirects: bool | None = None,
allow_redirects: bool | None = None,
timeout: httpx._types.TimeoutTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
extensions: dict[str, typing.Any] | None = None,
) -> httpx.Response:
redirect = self._choose_redirect_arg(follow_redirects, allow_redirects)
Expand All @@ -591,11 +589,11 @@ def head( # type: ignore[override]
headers: httpx._types.HeaderTypes | None = None,
cookies: httpx._types.CookieTypes | None = None,
auth: httpx._types.AuthTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
follow_redirects: bool | None = None,
allow_redirects: bool | None = None,
timeout: httpx._types.TimeoutTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
extensions: dict[str, typing.Any] | None = None,
) -> httpx.Response:
redirect = self._choose_redirect_arg(follow_redirects, allow_redirects)
Expand All @@ -622,11 +620,11 @@ def post( # type: ignore[override]
headers: httpx._types.HeaderTypes | None = None,
cookies: httpx._types.CookieTypes | None = None,
auth: httpx._types.AuthTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
follow_redirects: bool | None = None,
allow_redirects: bool | None = None,
timeout: httpx._types.TimeoutTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
extensions: dict[str, typing.Any] | None = None,
) -> httpx.Response:
redirect = self._choose_redirect_arg(follow_redirects, allow_redirects)
Expand Down Expand Up @@ -657,11 +655,11 @@ def put( # type: ignore[override]
headers: httpx._types.HeaderTypes | None = None,
cookies: httpx._types.CookieTypes | None = None,
auth: httpx._types.AuthTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
follow_redirects: bool | None = None,
allow_redirects: bool | None = None,
timeout: httpx._types.TimeoutTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
extensions: dict[str, typing.Any] | None = None,
) -> httpx.Response:
redirect = self._choose_redirect_arg(follow_redirects, allow_redirects)
Expand Down Expand Up @@ -692,11 +690,11 @@ def patch( # type: ignore[override]
headers: httpx._types.HeaderTypes | None = None,
cookies: httpx._types.CookieTypes | None = None,
auth: httpx._types.AuthTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
follow_redirects: bool | None = None,
allow_redirects: bool | None = None,
timeout: httpx._types.TimeoutTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
extensions: dict[str, typing.Any] | None = None,
) -> httpx.Response:
redirect = self._choose_redirect_arg(follow_redirects, allow_redirects)
Expand All @@ -723,11 +721,11 @@ def delete( # type: ignore[override]
headers: httpx._types.HeaderTypes | None = None,
cookies: httpx._types.CookieTypes | None = None,
auth: httpx._types.AuthTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
follow_redirects: bool | None = None,
allow_redirects: bool | None = None,
timeout: httpx._types.TimeoutTypes
| httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
| httpx._config.UseClientDefault = httpx.USE_CLIENT_DEFAULT,
extensions: dict[str, typing.Any] | None = None,
) -> httpx.Response:
redirect = self._choose_redirect_arg(follow_redirects, allow_redirects)
Expand Down