Skip to content

Commit

Permalink
remove deprecated request/response mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Nov 5, 2021
1 parent 897b9d8 commit 7b52ecd
Show file tree
Hide file tree
Showing 14 changed files with 8 additions and 356 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ Version 2.1.0

Unreleased

- Remove previously deprecated code. :pr:`2276`

- Request and response mixins have all been merged into the
``Request`` and ``Response`` classes.

- Default values passed to ``Headers`` are validated the same way
values added later are. :issue:`1608`
- Setting ``CacheControl`` int properties, such as ``max_age``, will
Expand Down
13 changes: 0 additions & 13 deletions src/werkzeug/wrappers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
from .accept import AcceptMixin
from .auth import AuthorizationMixin
from .auth import WWWAuthenticateMixin
from .base_request import BaseRequest
from .base_response import BaseResponse
from .common_descriptors import CommonRequestDescriptorsMixin
from .common_descriptors import CommonResponseDescriptorsMixin
from .etag import ETagRequestMixin
from .etag import ETagResponseMixin
from .request import PlainRequest
from .request import Request as Request
from .request import StreamOnlyMixin
from .response import Response as Response
from .response import ResponseStream
from .response import ResponseStreamMixin
from .user_agent import UserAgentMixin
14 changes: 0 additions & 14 deletions src/werkzeug/wrappers/accept.py

This file was deleted.

26 changes: 0 additions & 26 deletions src/werkzeug/wrappers/auth.py

This file was deleted.

36 changes: 0 additions & 36 deletions src/werkzeug/wrappers/base_request.py

This file was deleted.

36 changes: 0 additions & 36 deletions src/werkzeug/wrappers/base_response.py

This file was deleted.

26 changes: 0 additions & 26 deletions src/werkzeug/wrappers/common_descriptors.py

This file was deleted.

26 changes: 0 additions & 26 deletions src/werkzeug/wrappers/cors.py

This file was deleted.

26 changes: 0 additions & 26 deletions src/werkzeug/wrappers/etag.py

This file was deleted.

13 changes: 0 additions & 13 deletions src/werkzeug/wrappers/json.py

This file was deleted.

48 changes: 0 additions & 48 deletions src/werkzeug/wrappers/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,51 +610,3 @@ def on_json_loading_failed(self, e: ValueError) -> t.Any:
:exc:`~werkzeug.exceptions.BadRequest`.
"""
raise BadRequest(f"Failed to decode JSON object: {e}")


class StreamOnlyMixin:
"""Mixin to create a ``Request`` that disables the ``data``,
``form``, and ``files`` properties. Only ``stream`` is available.
.. deprecated:: 2.0
Will be removed in Werkzeug 2.1. Create the request with
``shallow=True`` instead.
.. versionadded:: 0.9
"""

def __init__(self, *args: t.Any, **kwargs: t.Any) -> None:
warnings.warn(
"'StreamOnlyMixin' is deprecated and will be removed in"
" Werkzeug 2.1. Create the request with 'shallow=True'"
" instead.",
DeprecationWarning,
stacklevel=2,
)
kwargs["shallow"] = True
super().__init__(*args, **kwargs) # type: ignore


class PlainRequest(StreamOnlyMixin, Request):
"""A request object without ``data``, ``form``, and ``files``.
.. deprecated:: 2.0
Will be removed in Werkzeug 2.1. Create the request with
``shallow=True`` instead.
.. versionadded:: 0.9
"""

def __init__(self, *args: t.Any, **kwargs: t.Any) -> None:
warnings.warn(
"'PlainRequest' is deprecated and will be removed in"
" Werkzeug 2.1. Create the request with 'shallow=True'"
" instead.",
DeprecationWarning,
stacklevel=2,
)

# Don't show the DeprecationWarning for StreamOnlyMixin.
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
super().__init__(*args, **kwargs)
18 changes: 3 additions & 15 deletions src/werkzeug/wrappers/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,9 +834,9 @@ def add_etag(self, overwrite: bool = False, weak: bool = False) -> None:


class ResponseStream:
"""A file descriptor like object used by the :class:`ResponseStreamMixin` to
represent the body of the stream. It directly pushes into the response
iterable of the response object.
"""A file descriptor like object used by :meth:`Response.stream` to
represent the body of the stream. It directly pushes into the
response iterable of the response object.
"""

mode = "wb+"
Expand Down Expand Up @@ -876,15 +876,3 @@ def tell(self) -> int:
@property
def encoding(self) -> str:
return self.response.charset


class ResponseStreamMixin:
def __init__(self, *args: t.Any, **kwargs: t.Any) -> None:
warnings.warn(
"'ResponseStreamMixin' is deprecated and will be removed in"
" Werkzeug 2.1. 'Response' now includes the functionality"
" directly.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs) # type: ignore
14 changes: 0 additions & 14 deletions src/werkzeug/wrappers/user_agent.py

This file was deleted.

0 comments on commit 7b52ecd

Please sign in to comment.