Skip to content

Commit

Permalink
typing: apply review feedmack
Browse files Browse the repository at this point in the history
  • Loading branch information
CaselIT committed Aug 11, 2024
1 parent bf887eb commit af41e56
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 66 deletions.
84 changes: 42 additions & 42 deletions falcon/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def on_get(self, req, resp):
from falcon.util.misc import dt_to_http

if TYPE_CHECKING:
from falcon.typing import NormalizedHeaders
from falcon.typing import RawHeaders
from falcon.typing import HeaderList
from falcon.typing import Headers


__all__ = (
Expand Down Expand Up @@ -229,7 +229,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
) -> None:
super().__init__(
Expand Down Expand Up @@ -312,7 +312,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
challenges: Optional[Iterable[str]] = None,
**kwargs: HTTPErrorKeywordArguments,
):
Expand Down Expand Up @@ -390,7 +390,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -461,7 +461,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -588,7 +588,7 @@ def __init__(
allowed_methods: Iterable[str],
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
headers = _load_headers(headers)
Expand Down Expand Up @@ -659,7 +659,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -732,7 +732,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -811,7 +811,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -875,7 +875,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -940,7 +940,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -1016,7 +1016,7 @@ def __init__(
title: Optional[str] = None,
description: Optional[str] = None,
retry_after: RetryAfter = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
) -> None:
super().__init__(
Expand Down Expand Up @@ -1086,7 +1086,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -1151,7 +1151,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -1230,7 +1230,7 @@ def __init__(
resource_length: int,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
headers = _load_headers(headers)
Expand Down Expand Up @@ -1300,7 +1300,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -1362,7 +1362,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -1423,7 +1423,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -1492,7 +1492,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -1566,7 +1566,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
retry_after: RetryAfter = None,
**kwargs: HTTPErrorKeywordArguments,
):
Expand Down Expand Up @@ -1635,7 +1635,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -1710,7 +1710,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -1771,7 +1771,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -1839,7 +1839,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -1900,7 +1900,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -1977,7 +1977,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
retry_after: RetryAfter = None,
**kwargs: HTTPErrorKeywordArguments,
):
Expand Down Expand Up @@ -2040,7 +2040,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -2107,7 +2107,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -2172,7 +2172,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -2234,7 +2234,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -2308,7 +2308,7 @@ def __init__(
self,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
super().__init__(
Expand Down Expand Up @@ -2367,7 +2367,7 @@ def __init__(
self,
msg: str,
header_name: str,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
description = 'The value provided for the "{0}" header is invalid. {1}'
Expand Down Expand Up @@ -2426,7 +2426,7 @@ class HTTPMissingHeader(HTTPBadRequest):
def __init__(
self,
header_name: str,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
):
description = 'The "{0}" header is required.'
Expand Down Expand Up @@ -2489,7 +2489,7 @@ def __init__(
self,
msg: str,
param_name: str,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
) -> None:
description = 'The "{0}" parameter is invalid. {1}'
Expand Down Expand Up @@ -2550,7 +2550,7 @@ class HTTPMissingParam(HTTPBadRequest):
def __init__(
self,
param_name: str,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
) -> None:
description = 'The "{0}" parameter is required.'
Expand Down Expand Up @@ -2649,7 +2649,7 @@ class MediaMalformedError(HTTPBadRequest):
"""

def __init__(
self, media_type: str, **kwargs: Union[RawHeaders, HTTPErrorKeywordArguments]
self, media_type: str, **kwargs: Union[HeaderList, HTTPErrorKeywordArguments]
):
super().__init__(
title='Invalid {0}'.format(media_type), description=None, **kwargs
Expand Down Expand Up @@ -2718,7 +2718,7 @@ def __init__(
*,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
**kwargs: HTTPErrorKeywordArguments,
) -> None:
super().__init__(
Expand Down Expand Up @@ -2753,7 +2753,7 @@ class MultipartParseError(MediaMalformedError):
def __init__(
self,
description: Optional[str] = None,
**kwargs: Union[RawHeaders, HTTPErrorKeywordArguments],
**kwargs: Union[HeaderList, HTTPErrorKeywordArguments],
) -> None:
HTTPBadRequest.__init__(
self,
Expand All @@ -2768,7 +2768,7 @@ def __init__(
# -----------------------------------------------------------------------------


def _load_headers(headers: Optional[RawHeaders]) -> NormalizedHeaders:
def _load_headers(headers: Optional[HeaderList]) -> Headers:
"""Transform the headers to dict."""
if headers is None:
return {}
Expand All @@ -2778,9 +2778,9 @@ def _load_headers(headers: Optional[RawHeaders]) -> NormalizedHeaders:


def _parse_retry_after(
headers: Optional[RawHeaders],
headers: Optional[HeaderList],
retry_after: RetryAfter,
) -> Optional[RawHeaders]:
) -> Optional[HeaderList]:
"""Set the Retry-After to the headers when required."""
if retry_after is None:
return headers
Expand Down
4 changes: 2 additions & 2 deletions falcon/http_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
from falcon.util.deprecation import deprecated_args

if TYPE_CHECKING:
from falcon.typing import HeaderList
from falcon.typing import Link
from falcon.typing import RawHeaders
from falcon.typing import Serializer
from falcon.typing import Status

Expand Down Expand Up @@ -123,7 +123,7 @@ def __init__(
status: Status,
title: Optional[str] = None,
description: Optional[str] = None,
headers: Optional[RawHeaders] = None,
headers: Optional[HeaderList] = None,
href: Optional[str] = None,
href_text: Optional[str] = None,
code: Optional[int] = None,
Expand Down
Loading

0 comments on commit af41e56

Please sign in to comment.