Skip to content

Commit

Permalink
style: run ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
CaselIT committed Aug 11, 2024
1 parent ff70cd3 commit bf887eb
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 48 deletions.
1 change: 1 addition & 0 deletions falcon/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

"""Falcon App class."""

from functools import wraps
from inspect import iscoroutinefunction
import pathlib
Expand Down
1 change: 1 addition & 0 deletions falcon/app_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

"""Utilities for the App class."""

from __future__ import annotations

from inspect import iscoroutinefunction
Expand Down
1 change: 1 addition & 0 deletions falcon/asgi_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

"""Constants, etc. defined by the ASGI specification."""

from __future__ import annotations


Expand Down
6 changes: 2 additions & 4 deletions falcon/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ def on_get(self, req, resp):
# -- snip --
"""

from __future__ import annotations

from datetime import datetime
from typing import Iterable
from typing import Optional
from typing import TYPE_CHECKING
from typing import Union
from typing import Iterable, Optional, TYPE_CHECKING, Union

from falcon.http_error import HTTPError
import falcon.status_codes as status
Expand Down
3 changes: 1 addition & 2 deletions falcon/forwarded.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

import re
import string
from typing import List
from typing import Optional
from typing import List, Optional

from falcon.util.uri import unquote_string

Expand Down
1 change: 1 addition & 0 deletions falcon/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

"""Hook decorators."""

from __future__ import annotations

from functools import wraps
Expand Down
7 changes: 2 additions & 5 deletions falcon/http_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""HTTPError exception class."""

from __future__ import annotations

from collections import OrderedDict
from typing import MutableMapping
from typing import Optional
from typing import Type
from typing import TYPE_CHECKING
from typing import Union
from typing import MutableMapping, Optional, Type, TYPE_CHECKING, Union
import xml.etree.ElementTree as et

from falcon.constants import MEDIA_JSON
Expand Down
4 changes: 2 additions & 2 deletions falcon/http_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""HTTPStatus exception class."""

from __future__ import annotations

from typing import Optional
from typing import TYPE_CHECKING
from typing import Optional, TYPE_CHECKING

from falcon.util import http_status_to_code
from falcon.util.deprecation import AttributeRemovedError
Expand Down
23 changes: 13 additions & 10 deletions falcon/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@
# limitations under the License.

"""Inspect utilities for falcon applications."""

from __future__ import annotations

from functools import partial
import inspect
from typing import Any
from typing import Callable
from typing import cast
from typing import Dict
from typing import Iterable
from typing import List
from typing import Optional
from typing import Tuple
from typing import Type
from typing import Union
from typing import (
Any,
Callable,
cast,
Dict,
Iterable,
List,
Optional,
Tuple,
Type,
Union,
)

from falcon import app_helpers
from falcon.app import App
Expand Down
3 changes: 2 additions & 1 deletion falcon/media/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
from falcon.util import misc
from falcon.vendor import mimeparse

if typing.TYPE_CHECKING: # pragma: no cover
if typing.TYPE_CHECKING: # pragma: no cover
from typing import Mapping

from falcon.typing import Serializer


Expand Down
5 changes: 1 addition & 4 deletions falcon/middleware.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from __future__ import annotations

from typing import Any
from typing import Iterable
from typing import Optional
from typing import Union
from typing import Any, Iterable, Optional, Union

from .request import Request
from .response import Response
Expand Down
4 changes: 2 additions & 2 deletions falcon/redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""HTTPStatus specializations for 3xx redirects."""

from __future__ import annotations

from typing import Optional
from typing import TYPE_CHECKING
from typing import Optional, TYPE_CHECKING

import falcon
from falcon.http_status import HTTPStatus
Expand Down
1 change: 1 addition & 0 deletions falcon/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# limitations under the License.

"""Request class."""

from __future__ import annotations

from collections import UserDict
Expand Down
4 changes: 2 additions & 2 deletions falcon/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
# limitations under the License.

"""Response class."""

from __future__ import annotations

import functools
import mimetypes
from typing import Optional
from typing import TYPE_CHECKING
from typing import Optional, TYPE_CHECKING

from falcon.constants import _DEFAULT_STATIC_MEDIA_TYPES
from falcon.constants import _UNSET
Expand Down
33 changes: 17 additions & 16 deletions falcon/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,40 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Shorthand definitions for more complex types."""

from __future__ import annotations

import http
from typing import Any
from typing import Callable
from typing import Dict
from typing import List
from typing import MutableMapping
from typing import Optional
from typing import Pattern
from typing import Tuple
from typing import TYPE_CHECKING
from typing import Union
from typing import (
Any,
Callable,
Dict,
List,
MutableMapping,
Optional,
Pattern,
Tuple,
TYPE_CHECKING,
Union,
)

if TYPE_CHECKING:
from typing import Protocol

from falcon.request import Request
from falcon.response import Response

from typing import Protocol

class Serializer(Protocol):
def serialize(
self,
media: MutableMapping[str, Union[str, int, None, Link]],
content_type: str,
) -> bytes:
...
) -> bytes: ...

class MediaHandlers(Protocol):
def _resolve(
self, media_type: str, default: str, raise_not_found: bool = False
) -> Tuple[Serializer, Optional[Callable], Optional[Callable]]:
...
) -> Tuple[Serializer, Optional[Callable], Optional[Callable]]: ...


Link = Dict[str, str]
Expand Down

0 comments on commit bf887eb

Please sign in to comment.