Skip to content

Improve response handling and type annotations #742

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import HTTPStatus
from typing import Any, Dict, Optional, Union
from typing import Any, Dict, Union

import httpx

Expand Down Expand Up @@ -34,7 +34,7 @@ def _get_kwargs(
}


def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
def _parse_response(*, client: Client, response: httpx.Response) -> None:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
Expand All @@ -43,20 +43,20 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
def _build_response(*, client: Client, response: httpx.Response) -> Response[None]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
parsed=_parse_response(client=client, response=response), # type: ignore[func-returns-value]
)


def sync_detailed(
*,
client: Client,
common: Union[Unset, None, str] = UNSET,
) -> Response[Any]:
) -> Response[None]:
"""
Args:
common (Union[Unset, None, str]):
Expand All @@ -66,7 +66,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any]
Response[None]
"""

kwargs = _get_kwargs(
Expand All @@ -86,7 +86,7 @@ async def asyncio_detailed(
*,
client: Client,
common: Union[Unset, None, str] = UNSET,
) -> Response[Any]:
) -> Response[None]:
"""
Args:
common (Union[Unset, None, str]):
Expand All @@ -96,7 +96,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any]
Response[None]
"""

kwargs = _get_kwargs(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import HTTPStatus
from typing import Any, Dict, Optional, Union
from typing import Any, Dict, Union

import httpx

Expand Down Expand Up @@ -34,7 +34,7 @@ def _get_kwargs(
}


def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
def _parse_response(*, client: Client, response: httpx.Response) -> None:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
Expand All @@ -43,20 +43,20 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
def _build_response(*, client: Client, response: httpx.Response) -> Response[None]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
parsed=_parse_response(client=client, response=response), # type: ignore[func-returns-value]
)


def sync_detailed(
*,
client: Client,
common: Union[Unset, None, str] = UNSET,
) -> Response[Any]:
) -> Response[None]:
"""
Args:
common (Union[Unset, None, str]):
Expand All @@ -66,7 +66,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any]
Response[None]
"""

kwargs = _get_kwargs(
Expand All @@ -86,7 +86,7 @@ async def asyncio_detailed(
*,
client: Client,
common: Union[Unset, None, str] = UNSET,
) -> Response[Any]:
) -> Response[None]:
"""
Args:
common (Union[Unset, None, str]):
Expand All @@ -96,7 +96,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any]
Response[None]
"""

kwargs = _get_kwargs(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import HTTPStatus
from typing import Any, Dict, Optional, Union
from typing import Any, Dict, Union

import httpx

Expand Down Expand Up @@ -53,7 +53,7 @@ def _get_kwargs(
}


def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
def _parse_response(*, client: Client, response: httpx.Response) -> None:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
Expand All @@ -62,12 +62,12 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
def _build_response(*, client: Client, response: httpx.Response) -> Response[None]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
parsed=_parse_response(client=client, response=response), # type: ignore[func-returns-value]
)


Expand All @@ -80,7 +80,7 @@ def sync_detailed(
integer_header: Union[Unset, int] = UNSET,
int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET,
string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET,
) -> Response[Any]:
) -> Response[None]:
"""
Args:
boolean_header (Union[Unset, bool]):
Expand All @@ -95,7 +95,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any]
Response[None]
"""

kwargs = _get_kwargs(
Expand Down Expand Up @@ -125,7 +125,7 @@ async def asyncio_detailed(
integer_header: Union[Unset, int] = UNSET,
int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET,
string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET,
) -> Response[Any]:
) -> Response[None]:
"""
Args:
boolean_header (Union[Unset, bool]):
Expand All @@ -140,7 +140,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any]
Response[None]
"""

kwargs = _get_kwargs(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime
from http import HTTPStatus
from typing import Any, Dict, Optional, Union
from typing import Any, Dict, Union

import httpx

Expand Down Expand Up @@ -58,7 +58,7 @@ def _get_kwargs(
}


def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
def _parse_response(*, client: Client, response: httpx.Response) -> None:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
Expand All @@ -67,12 +67,12 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
def _build_response(*, client: Client, response: httpx.Response) -> Response[None]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
parsed=_parse_response(client=client, response=response), # type: ignore[func-returns-value]
)


Expand All @@ -83,7 +83,7 @@ def sync_detailed(
null_required: Union[Unset, None, datetime.datetime] = UNSET,
null_not_required: Union[Unset, None, datetime.datetime] = UNSET,
not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET,
) -> Response[Any]:
) -> Response[None]:
"""
Args:
not_null_required (datetime.datetime):
Expand All @@ -96,7 +96,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any]
Response[None]
"""

kwargs = _get_kwargs(
Expand All @@ -122,7 +122,7 @@ async def asyncio_detailed(
null_required: Union[Unset, None, datetime.datetime] = UNSET,
null_not_required: Union[Unset, None, datetime.datetime] = UNSET,
not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET,
) -> Response[Any]:
) -> Response[None]:
"""
Args:
not_null_required (datetime.datetime):
Expand All @@ -135,7 +135,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any]
Response[None]
"""

kwargs = _get_kwargs(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import HTTPStatus
from typing import Any, Dict, Optional, Union
from typing import Any, Dict, Union

import httpx

Expand Down Expand Up @@ -46,7 +46,7 @@ def _get_kwargs(
}


def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
def _parse_response(*, client: Client, response: httpx.Response) -> None:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
Expand All @@ -55,12 +55,12 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
def _build_response(*, client: Client, response: httpx.Response) -> Response[None]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
parsed=_parse_response(client=client, response=response), # type: ignore[func-returns-value]
)


Expand All @@ -72,7 +72,7 @@ def sync_detailed(
integer_param: Union[Unset, None, int] = 0,
header_param: Union[Unset, str] = UNSET,
cookie_param: Union[Unset, str] = UNSET,
) -> Response[Any]:
) -> Response[None]:
"""Test different types of parameter references

Args:
Expand All @@ -87,7 +87,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any]
Response[None]
"""

kwargs = _get_kwargs(
Expand Down Expand Up @@ -115,7 +115,7 @@ async def asyncio_detailed(
integer_param: Union[Unset, None, int] = 0,
header_param: Union[Unset, str] = UNSET,
cookie_param: Union[Unset, str] = UNSET,
) -> Response[Any]:
) -> Response[None]:
"""Test different types of parameter references

Args:
Expand All @@ -130,7 +130,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any]
Response[None]
"""

kwargs = _get_kwargs(
Expand Down
Loading