use ruff linter and formatter

This commit is contained in:
David Lord 2023-11-09 09:20:27 -08:00
parent 14232513fd
commit 54e05a2824
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
26 changed files with 99 additions and 132 deletions

View file

@ -1183,7 +1183,8 @@ class Flask(App):
# class to the correct type
try:
rv = self.response_class.force_type(
rv, request.environ # type: ignore[arg-type]
rv, # type: ignore[arg-type]
request.environ,
)
except TypeError as e:
raise TypeError(
@ -1272,7 +1273,8 @@ class Flask(App):
return response
def do_teardown_request(
self, exc: BaseException | None = _sentinel # type: ignore
self,
exc: BaseException | None = _sentinel, # type: ignore[assignment]
) -> None:
"""Called after the request is dispatched and the response is
returned, right before the request context is popped.
@ -1305,7 +1307,8 @@ class Flask(App):
request_tearing_down.send(self, _async_wrapper=self.ensure_sync, exc=exc)
def do_teardown_appcontext(
self, exc: BaseException | None = _sentinel # type: ignore
self,
exc: BaseException | None = _sentinel, # type: ignore[assignment]
) -> None:
"""Called right before the application context is popped.

View file

@ -21,6 +21,7 @@ from .signals import message_flashed
if t.TYPE_CHECKING: # pragma: no cover
from werkzeug.wrappers import Response as BaseResponse
from .wrappers import Response
@ -48,9 +49,7 @@ def get_load_dotenv(default: bool = True) -> bool:
def stream_with_context(
generator_or_function: (
t.Iterator[t.AnyStr] | t.Callable[..., t.Iterator[t.AnyStr]]
)
generator_or_function: t.Iterator[t.AnyStr] | t.Callable[..., t.Iterator[t.AnyStr]]
) -> t.Iterator[t.AnyStr]:
"""Request contexts disappear when the response is started on the server.
This is done for efficiency reasons and to make it less likely to encounter

View file

@ -134,9 +134,7 @@ class DefaultJSONProvider(JSONProvider):
method) will call the ``__html__`` method to get a string.
"""
default: t.Callable[[t.Any], t.Any] = staticmethod(
_default
) # type: ignore[assignment]
default: t.Callable[[t.Any], t.Any] = staticmethod(_default) # type: ignore[assignment]
"""Apply this function to any object that :meth:`json.dumps` does
not know how to serialize. It should return a valid JSON type or
raise a ``TypeError``.

View file

@ -35,9 +35,10 @@ from .scaffold import setupmethod
if t.TYPE_CHECKING: # pragma: no cover
from werkzeug.wrappers import Response as BaseResponse
from .blueprints import Blueprint
from ..testing import FlaskClient
from ..testing import FlaskCliRunner
from .blueprints import Blueprint
T_shell_context_processor = t.TypeVar(
"T_shell_context_processor", bound=ft.ShellContextProcessorCallable
@ -905,7 +906,9 @@ class App(Scaffold):
Moved from ``flask.redirect``, which calls this method.
"""
return _wz_redirect(
location, code=code, Response=self.response_class # type: ignore[arg-type]
location,
code=code,
Response=self.response_class, # type: ignore[arg-type]
)
def inject_url_defaults(self, endpoint: str, values: dict) -> None:

View file

@ -14,7 +14,8 @@ from .json.tag import TaggedJSONSerializer
if t.TYPE_CHECKING: # pragma: no cover
from .app import Flask
from .wrappers import Request, Response
from .wrappers import Request
from .wrappers import Response
class SessionMixin(MutableMapping):

View file

@ -6,7 +6,6 @@ from . import typing as ft
from .globals import current_app
from .globals import request
http_method_funcs = frozenset(
["get", "post", "head", "options", "delete", "put", "trace", "patch"]
)