Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 1, 2024
1 parent 05cb491 commit 465e106
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 47 deletions.
12 changes: 4 additions & 8 deletions src/werkzeug/_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,11 @@ def _log(type: str, message: str, *args: t.Any, **kwargs: t.Any) -> None:


@t.overload
def _dt_as_utc(dt: None) -> None:
...
def _dt_as_utc(dt: None) -> None: ...


@t.overload
def _dt_as_utc(dt: datetime) -> datetime:
...
def _dt_as_utc(dt: datetime) -> datetime: ...


def _dt_as_utc(dt: datetime | None) -> datetime | None:
Expand Down Expand Up @@ -149,12 +147,10 @@ def lookup(self, instance: t.Any) -> t.MutableMapping[str, t.Any]:
@t.overload
def __get__(
self, instance: None, owner: type
) -> _DictAccessorProperty[_TAccessorValue]:
...
) -> _DictAccessorProperty[_TAccessorValue]: ...

@t.overload
def __get__(self, instance: t.Any, owner: type) -> _TAccessorValue:
...
def __get__(self, instance: t.Any, owner: type) -> _TAccessorValue: ...

def __get__(
self, instance: t.Any | None, owner: type
Expand Down
2 changes: 1 addition & 1 deletion src/werkzeug/datastructures/structures.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ _CD = TypeVar("_CD", bound="CallbackDict")

def is_immutable(self: object) -> NoReturn: ...
def iter_multi_items(
mapping: Mapping[K, V | Iterable[V]] | Iterable[tuple[K, V]]
mapping: Mapping[K, V | Iterable[V]] | Iterable[tuple[K, V]],
) -> Iterator[tuple[K, V]]: ...

class ImmutableList(ImmutableListMixin[V]): ...
Expand Down
1 change: 1 addition & 0 deletions src/werkzeug/debug/repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Together with the CSS and JavaScript of the debugger this gives a
colorful and more compact output.
"""

from __future__ import annotations

import codecs
Expand Down
1 change: 1 addition & 0 deletions src/werkzeug/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def application(request):
return e
"""

from __future__ import annotations

import typing as t
Expand Down
3 changes: 1 addition & 2 deletions src/werkzeug/formparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def __call__(
content_type: str | None,
filename: str | None,
content_length: int | None = None,
) -> t.IO[bytes]:
...
) -> t.IO[bytes]: ...


F = t.TypeVar("F", bound=t.Callable[..., t.Any])
Expand Down
18 changes: 6 additions & 12 deletions src/werkzeug/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,13 +553,11 @@ def parse_options_header(value: str | None) -> tuple[str, dict[str, str]]:


@t.overload
def parse_accept_header(value: str | None) -> ds.Accept:
...
def parse_accept_header(value: str | None) -> ds.Accept: ...


@t.overload
def parse_accept_header(value: str | None, cls: type[_TAnyAccept]) -> _TAnyAccept:
...
def parse_accept_header(value: str | None, cls: type[_TAnyAccept]) -> _TAnyAccept: ...


def parse_accept_header(
Expand Down Expand Up @@ -622,15 +620,13 @@ def parse_accept_header(
@t.overload
def parse_cache_control_header(
value: str | None, on_update: _t_cc_update, cls: None = None
) -> ds.RequestCacheControl:
...
) -> ds.RequestCacheControl: ...


@t.overload
def parse_cache_control_header(
value: str | None, on_update: _t_cc_update, cls: type[_TAnyCC]
) -> _TAnyCC:
...
) -> _TAnyCC: ...


def parse_cache_control_header(
Expand Down Expand Up @@ -670,15 +666,13 @@ def parse_cache_control_header(
@t.overload
def parse_csp_header(
value: str | None, on_update: _t_csp_update, cls: None = None
) -> ds.ContentSecurityPolicy:
...
) -> ds.ContentSecurityPolicy: ...


@t.overload
def parse_csp_header(
value: str | None, on_update: _t_csp_update, cls: type[_TAnyCSP]
) -> _TAnyCSP:
...
) -> _TAnyCSP: ...


def parse_csp_header(
Expand Down
1 change: 1 addition & 0 deletions src/werkzeug/middleware/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
:copyright: 2007 Pallets
:license: BSD-3-Clause
"""

from __future__ import annotations

import typing as t
Expand Down
1 change: 1 addition & 0 deletions src/werkzeug/middleware/http_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:copyright: 2007 Pallets
:license: BSD-3-Clause
"""

from __future__ import annotations

import typing as t
Expand Down
5 changes: 3 additions & 2 deletions src/werkzeug/middleware/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
:copyright: 2007 Pallets
:license: BSD-3-Clause
"""

from __future__ import annotations

import typing as t
Expand Down Expand Up @@ -424,8 +425,8 @@ def checking_start_response(

status: str = args[0]
headers: list[tuple[str, str]] = args[1]
exc_info: None | (
tuple[type[BaseException], BaseException, TracebackType]
exc_info: (
None | (tuple[type[BaseException], BaseException, TracebackType])
) = args[2] if len(args) == 3 else None

headers_set[:] = self.check_start_response(status, headers, exc_info)
Expand Down
1 change: 1 addition & 0 deletions src/werkzeug/middleware/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
:copyright: 2007 Pallets
:license: BSD-3-Clause
"""

from __future__ import annotations

import os.path
Expand Down
1 change: 1 addition & 0 deletions src/werkzeug/middleware/proxy_fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
:copyright: 2007 Pallets
:license: BSD-3-Clause
"""

from __future__ import annotations

import typing as t
Expand Down
2 changes: 1 addition & 1 deletion src/werkzeug/middleware/shared_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:copyright: 2007 Pallets
:license: BSD-3-Clause
"""

from __future__ import annotations

import importlib.util
Expand Down Expand Up @@ -38,7 +39,6 @@


class SharedDataMiddleware:

"""A WSGI middleware which provides static content for development
environments or simple server setups. Its usage is quite simple::
Expand Down
1 change: 1 addition & 0 deletions src/werkzeug/routing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
routing tried to match a ``POST`` request) a ``MethodNotAllowed``
exception is raised.
"""

from .converters import AnyConverter as AnyConverter
from .converters import BaseConverter as BaseConverter
from .converters import FloatConverter as FloatConverter
Expand Down
7 changes: 2 additions & 5 deletions src/werkzeug/routing/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ def __repr__(self) -> str:


class MapAdapter:

"""Returned by :meth:`Map.bind` or :meth:`Map.bind_to_environ` and does
the URL matching and building based on runtime information.
"""
Expand Down Expand Up @@ -477,8 +476,7 @@ def match( # type: ignore
return_rule: t.Literal[False] = False,
query_args: t.Mapping[str, t.Any] | str | None = None,
websocket: bool | None = None,
) -> tuple[str, t.Mapping[str, t.Any]]:
...
) -> tuple[str, t.Mapping[str, t.Any]]: ...

@t.overload
def match(
Expand All @@ -488,8 +486,7 @@ def match(
return_rule: t.Literal[True] = True,
query_args: t.Mapping[str, t.Any] | str | None = None,
websocket: bool | None = None,
) -> tuple[Rule, t.Mapping[str, t.Any]]:
...
) -> tuple[Rule, t.Mapping[str, t.Any]]: ...

def match(
self,
Expand Down
1 change: 1 addition & 0 deletions src/werkzeug/serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from myapp import create_app
from werkzeug import run_simple
"""

from __future__ import annotations

import errno
Expand Down
1 change: 1 addition & 0 deletions src/werkzeug/testapp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""A small application that can be used to test a WSGI server and check
it for WSGI compliance.
"""

from __future__ import annotations

import os
Expand Down
12 changes: 4 additions & 8 deletions src/werkzeug/wrappers/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,15 @@ def get_data( # type: ignore
cache: bool = True,
as_text: t.Literal[False] = False,
parse_form_data: bool = False,
) -> bytes:
...
) -> bytes: ...

@t.overload
def get_data(
self,
cache: bool = True,
as_text: t.Literal[True] = ...,
parse_form_data: bool = False,
) -> str:
...
) -> str: ...

def get_data(
self, cache: bool = True, as_text: bool = False, parse_form_data: bool = False
Expand Down Expand Up @@ -564,14 +562,12 @@ def json(self) -> t.Any | None:
@t.overload
def get_json(
self, force: bool = ..., silent: t.Literal[False] = ..., cache: bool = ...
) -> t.Any:
...
) -> t.Any: ...

@t.overload
def get_json(
self, force: bool = ..., silent: bool = ..., cache: bool = ...
) -> t.Any | None:
...
) -> t.Any | None: ...

def get_json(
self, force: bool = False, silent: bool = False, cache: bool = True
Expand Down
12 changes: 4 additions & 8 deletions src/werkzeug/wrappers/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,10 @@ def from_app(
return cls(*run_wsgi_app(app, environ, buffered))

@t.overload
def get_data(self, as_text: t.Literal[False] = False) -> bytes:
...
def get_data(self, as_text: t.Literal[False] = False) -> bytes: ...

@t.overload
def get_data(self, as_text: t.Literal[True]) -> str:
...
def get_data(self, as_text: t.Literal[True]) -> str: ...

def get_data(self, as_text: bool = False) -> bytes | str:
"""The string representation of the response body. Whenever you call
Expand Down Expand Up @@ -595,12 +593,10 @@ def json(self) -> t.Any | None:
return self.get_json()

@t.overload
def get_json(self, force: bool = ..., silent: t.Literal[False] = ...) -> t.Any:
...
def get_json(self, force: bool = ..., silent: t.Literal[False] = ...) -> t.Any: ...

@t.overload
def get_json(self, force: bool = ..., silent: bool = ...) -> t.Any | None:
...
def get_json(self, force: bool = ..., silent: bool = ...) -> t.Any | None: ...

def get_json(self, force: bool = False, silent: bool = False) -> t.Any | None:
"""Parse :attr:`data` as JSON. Useful during testing.
Expand Down

0 comments on commit 465e106

Please sign in to comment.