better and clean;

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2023-05-08 12:58:35 -07:00
parent c209414459
commit 8cf515b39f
92 changed files with 2619 additions and 1373 deletions

View File

@ -30,7 +30,7 @@ def _get_kwargs(
def _parse_response(
*, response: httpx.Response
) -> Optional[Union[Any, VerificationToken, Error]]:
) -> Optional[Union[VerificationToken, Error]]:
if response.status_code == 201:
response_201 = VerificationToken.from_dict(response.json())
return response_201
@ -40,12 +40,12 @@ def _parse_response(
if response.status_code == 500:
response_5XX = Error.from_dict(response.json())
return response_5XX
return None
return Error.from_dict(response.json())
def _build_response(
*, response: httpx.Response
) -> Response[Union[Any, VerificationToken, Error]]:
) -> Response[Optional[Union[VerificationToken, Error]]]:
return Response(
status_code=response.status_code,
content=response.content,
@ -58,7 +58,7 @@ def sync_detailed(
body: EmailAuthenticationForm,
*,
client: Client,
) -> Response[Union[Any, VerificationToken, Error]]:
) -> Response[Optional[Union[VerificationToken, Error]]]:
kwargs = _get_kwargs(
body=body,
client=client,
@ -76,7 +76,7 @@ def sync(
body: EmailAuthenticationForm,
*,
client: Client,
) -> Optional[Union[Any, VerificationToken, Error]]:
) -> Optional[Union[VerificationToken, Error]]:
return sync_detailed(
body=body,
@ -88,7 +88,7 @@ async def asyncio_detailed(
body: EmailAuthenticationForm,
*,
client: Client,
) -> Response[Union[Any, VerificationToken, Error]]:
) -> Response[Optional[Union[VerificationToken, Error]]]:
kwargs = _get_kwargs(
body=body,
client=client,
@ -104,7 +104,7 @@ async def asyncio(
body: EmailAuthenticationForm,
*,
client: Client,
) -> Optional[Union[Any, VerificationToken, Error]]:
) -> Optional[Union[VerificationToken, Error]]:
return (
await asyncio_detailed(

View File

@ -1,4 +1,4 @@
from typing import Any, Dict, Optional, Union
from typing import Any, Dict, Optional
import httpx
@ -42,20 +42,18 @@ def _get_kwargs(
}
def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, Error]]:
if response.status_code == 302:
response_302 = None
return response_302
def _parse_response(*, response: httpx.Response) -> Optional[Error]:
return None
if response.status_code == 400:
response_4XX = Error.from_dict(response.json())
return response_4XX
if response.status_code == 500:
response_5XX = Error.from_dict(response.json())
return response_5XX
return None
return Error.from_dict(response.json())
def _build_response(*, response: httpx.Response) -> Response[Union[Any, Error]]:
def _build_response(*, response: httpx.Response) -> Response[Optional[Error]]:
return Response(
status_code=response.status_code,
content=response.content,
@ -70,7 +68,7 @@ def sync_detailed(
*,
client: Client,
callback_url: Optional[str] = None,
) -> Response[Union[Any, Error]]:
) -> Response[Optional[Error]]:
kwargs = _get_kwargs(
callback_url=callback_url,
email=email,
@ -92,7 +90,7 @@ def sync(
*,
client: Client,
callback_url: Optional[str] = None,
) -> Optional[Union[Any, Error]]:
) -> Optional[Error]:
return sync_detailed(
callback_url=callback_url,
@ -108,7 +106,7 @@ async def asyncio_detailed(
*,
client: Client,
callback_url: Optional[str] = None,
) -> Response[Union[Any, Error]]:
) -> Response[Optional[Error]]:
kwargs = _get_kwargs(
callback_url=callback_url,
email=email,
@ -128,7 +126,7 @@ async def asyncio(
*,
client: Client,
callback_url: Optional[str] = None,
) -> Optional[Union[Any, Error]]:
) -> Optional[Error]:
return (
await asyncio_detailed(

View File

@ -1,4 +1,4 @@
from typing import Any, Dict, Optional, Union
from typing import Any, Dict, Optional
import httpx
@ -24,20 +24,18 @@ def _get_kwargs(
}
def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, Error]]:
if response.status_code == 204:
response_204 = None
return response_204
def _parse_response(*, response: httpx.Response) -> Optional[Error]:
return None
if response.status_code == 400:
response_4XX = Error.from_dict(response.json())
return response_4XX
if response.status_code == 500:
response_5XX = Error.from_dict(response.json())
return response_5XX
return None
return Error.from_dict(response.json())
def _build_response(*, response: httpx.Response) -> Response[Union[Any, Error]]:
def _build_response(*, response: httpx.Response) -> Response[Optional[Error]]:
return Response(
status_code=response.status_code,
content=response.content,
@ -49,7 +47,7 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, Error]]:
def sync_detailed(
*,
client: Client,
) -> Response[Union[Any, Error]]:
) -> Response[Optional[Error]]:
kwargs = _get_kwargs(
client=client,
)
@ -65,7 +63,7 @@ def sync_detailed(
def sync(
*,
client: Client,
) -> Optional[Union[Any, Error]]:
) -> Optional[Error]:
"""This is used in logout scenarios.""" # noqa: E501
return sync_detailed(
@ -76,7 +74,7 @@ def sync(
async def asyncio_detailed(
*,
client: Client,
) -> Response[Union[Any, Error]]:
) -> Response[Optional[Error]]:
kwargs = _get_kwargs(
client=client,
)
@ -90,7 +88,7 @@ async def asyncio_detailed(
async def asyncio(
*,
client: Client,
) -> Optional[Union[Any, Error]]:
) -> Optional[Error]:
"""This is used in logout scenarios.""" # noqa: E501
return (