Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove deprecated code #2276

Merged
merged 21 commits into from
Nov 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7b52ecd
remove deprecated request/response mixins
davidism Nov 5, 2021
7d3933e
remove deprecated has_key method
davidism Nov 5, 2021
a4608ed
remove deprecated cache_property name
davidism Nov 5, 2021
28fa9cc
remove deprecated user agent parser
davidism Nov 5, 2021
c364c52
remove deprecated Request.disable_data_descriptor
davidism Nov 5, 2021
c5677d0
remove deprecated Response.freeze no_etag parameter
davidism Nov 5, 2021
7d2784f
remove deprecated test response tuple behavior
davidism Nov 5, 2021
8665e2f
remove deprecated HTTPException.wrap method
davidism Nov 5, 2021
3ae3abb
remove deprecated parse_multipart_headers
davidism Nov 5, 2021
8c82bf4
remove deprecated cookie_date function
davidism Nov 5, 2021
047762d
remove deprecated dev server shutdown function
davidism Nov 5, 2021
1e504e2
remove deprecated werkzeug.serving cli
davidism Nov 5, 2021
a0e15e6
remove deprecated run_with_reloader internal function
davidism Nov 5, 2021
9dee4cd
remove deprecated thread-local code from locals
davidism Nov 5, 2021
7fff62f
remove deprecated pbkdf2 security functions
davidism Nov 5, 2021
2289ea0
remove deprecated invalidate_cached_property
davidism Nov 5, 2021
a28aaa6
remove deprecated HTMLBuilder class
davidism Nov 6, 2021
ee63ecb
remove deprecated bind_arguments and validate_arguments
davidism Nov 6, 2021
d13625a
remove deprecated detect_utf_encoding
davidism Nov 6, 2021
70fc801
remove deprecated format_string
davidism Nov 6, 2021
22d1e9a
remove deprecated escape and unescape
davidism Nov 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,44 @@ Version 2.1.0

Unreleased

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

- Remove the non-standard ``shutdown`` function from the WSGI
environ when running the development server. See the docs for
alternatives.
- Request and response mixins have all been merged into the
``Request`` and ``Response`` classes.
- The user agent parser and the ``useragents`` module is removed.
The ``user_agent`` module provides an interface that can be
subclassed to add a parser, such as ua-parser. By default it
only stores the whole string.
- The test client returns ``TestResponse`` instances and can no
longer be treated as a tuple. All data is available as
properties on the response.
- Remove ``locals.get_ident`` and related thread-local code from
``locals``, it no longer makes sense when moving to a
contextvars-based implementation.
- Remove the ``python -m werkzeug.serving`` CLI.
- The ``has_key`` method on some mapping datastructures; use
``key in data`` instead.
- ``Request.disable_data_descriptor`` is removed, pass
``shallow=True`` instead.
- Remove the ``no_etag`` parameter from ``Response.freeze()``.
- Remove the ``HTTPException.wrap`` class method.
- Remove the ``cookie_date`` function. Use ``http_date`` instead.
- Remove the ``pbkdf2_hex``, ``pbkdf2_bin``, and ``safe_str_cmp``
functions. Use equivalents in ``hashlib`` and ``hmac`` modules
instead.
- Remove the ``Href`` class.
- Remove the ``HTMLBuilder`` class.
- Remove the ``invalidate_cached_property`` function. Use
``del obj.attr`` instead.
- Remove ``bind_arguments`` and ``validate_arguments``. Use
:meth:`Signature.bind` and :func:`inspect.signature` instead.
- Remove ``detect_utf_encoding``, it's built-in to ``json.loads``.
- Remove ``format_string``, use :class:`string.Template` instead.
- Remove ``escape`` and ``unescape``. Use MarkupSafe instead.

- 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
2 changes: 0 additions & 2 deletions docs/http.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ naive.

.. autofunction:: http_date

.. autofunction:: cookie_date


Header Parsing
==============
Expand Down
2 changes: 1 addition & 1 deletion docs/local.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ context.
.. autofunction:: release_local

.. autoclass:: LocalManager
:members: cleanup, make_middleware, middleware, get_ident
:members: cleanup, make_middleware, middleware

.. autoclass:: LocalStack
:members: push, pop, top
Expand Down
21 changes: 0 additions & 21 deletions docs/serving.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,27 +148,6 @@ technique and should be preferred for security. Another method could be
to start a :mod:`subprocess` process and send the value back over
``stdout``.

.. deprecated:: 2.0

Shutting down the server with
``environ["werkzeug.server.shutdown"]`` is deprecated and will be
removed in Werkzeug 2.1.

The development server provides a way to shutdown the server from a
request. This will only work with the development server. The
development server injects a function into the WSGI environ with the
``"werkzeug.server.shutdown"`` key.

.. code-block:: python

def shutdown_server(environ):
shutdown = environ.get("werkzeug.server.shutdown")

if shutdown is None:
raise RuntimeError("Not running the development server.")

shutdown()


Troubleshooting
---------------
Expand Down
40 changes: 0 additions & 40 deletions docs/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,15 @@ Utilities

Various utility functions shipped with Werkzeug.


HTML Helpers
============

.. module:: werkzeug.utils

.. autoclass:: HTMLBuilder

.. autofunction:: escape

.. autofunction:: unescape


General Helpers
===============

.. autoclass:: cached_property
:members:

.. autofunction:: invalidate_cached_property

.. autoclass:: environ_property

.. autoclass:: header_property
Expand All @@ -39,12 +27,8 @@ General Helpers

.. autofunction:: find_modules

.. autofunction:: validate_arguments

.. autofunction:: secure_filename

.. autofunction:: bind_arguments


URL Helpers
===========
Expand All @@ -62,41 +46,17 @@ User Agent API
:member-order: bysource


UserAgent Parsing (deprecated)
==============================

.. module:: werkzeug.useragents

.. deprecated:: 2.0
This module will be removed in Werkzeug 2.1. Subclass
:class:`werkzeug.user_agent.UserAgent` to use a dedicated parser
instead.

.. autoclass:: UserAgent
:members:
:inherited-members:
:member-order: bysource


Security Helpers
================

.. module:: werkzeug.security

.. versionadded:: 0.6.1

.. autofunction:: generate_password_hash

.. autofunction:: check_password_hash

.. autofunction:: safe_str_cmp

.. autofunction:: safe_join

.. autofunction:: pbkdf2_hex

.. autofunction:: pbkdf2_bin


Logging
=======
Expand Down
78 changes: 0 additions & 78 deletions src/werkzeug/_internal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import inspect
import logging
import operator
import re
Expand Down Expand Up @@ -225,83 +224,6 @@ def _log(type: str, message: str, *args: t.Any, **kwargs: t.Any) -> None:
getattr(_logger, type)(message.rstrip(), *args, **kwargs)


def _parse_signature(func): # type: ignore
"""Return a signature object for the function.

.. deprecated:: 2.0
Will be removed in Werkzeug 2.1 along with ``utils.bind`` and
``validate_arguments``.
"""
# if we have a cached validator for this function, return it
parse = _signature_cache.get(func)
if parse is not None:
return parse

# inspect the function signature and collect all the information
tup = inspect.getfullargspec(func)
positional, vararg_var, kwarg_var, defaults = tup[:4]
defaults = defaults or ()
arg_count = len(positional)
arguments = []
for idx, name in enumerate(positional):
if isinstance(name, list):
raise TypeError(
"cannot parse functions that unpack tuples in the function signature"
)
try:
default = defaults[idx - arg_count]
except IndexError:
param = (name, False, None)
else:
param = (name, True, default)
arguments.append(param)
arguments = tuple(arguments)

def parse(args, kwargs): # type: ignore
new_args = []
missing = []
extra = {}

# consume as many arguments as positional as possible
for idx, (name, has_default, default) in enumerate(arguments):
try:
new_args.append(args[idx])
except IndexError:
try:
new_args.append(kwargs.pop(name))
except KeyError:
if has_default:
new_args.append(default)
else:
missing.append(name)
else:
if name in kwargs:
extra[name] = kwargs.pop(name)

# handle extra arguments
extra_positional = args[arg_count:]
if vararg_var is not None:
new_args.extend(extra_positional)
extra_positional = ()
if kwargs and kwarg_var is None:
extra.update(kwargs)
kwargs = {}

return (
new_args,
kwargs,
missing,
extra,
extra_positional,
arguments,
vararg_var,
kwarg_var,
)

_signature_cache[func] = parse
return parse


@typing.overload
def _dt_as_utc(dt: None) -> None:
...
Expand Down
39 changes: 0 additions & 39 deletions src/werkzeug/datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import codecs
import mimetypes
import re
import warnings
from collections.abc import Collection
from collections.abc import MutableSet
from copy import deepcopy
Expand Down Expand Up @@ -1082,20 +1081,6 @@ def __contains__(self, key):
return False
return True

def has_key(self, key):
"""
.. deprecated:: 2.0
Will be removed in Werkzeug 2.1. Use ``key in data``
instead.
"""
warnings.warn(
"'has_key' is deprecated and will be removed in Werkzeug"
" 2.1. Use 'key in data' instead.",
DeprecationWarning,
stacklevel=2,
)
return key in self

def __iter__(self):
"""Yield ``(key, value)`` tuples."""
return iter(self._list)
Expand Down Expand Up @@ -1548,20 +1533,6 @@ def __contains__(self, key):
return True
return False

def has_key(self, key):
"""
.. deprecated:: 2.0
Will be removed in Werkzeug 2.1. Use ``key in data``
instead.
"""
warnings.warn(
"'has_key' is deprecated and will be removed in Werkzeug"
" 2.1. Use 'key in data' instead.",
DeprecationWarning,
stacklevel=2,
)
return key in self

def __repr__(self):
return f"{type(self).__name__}({self.dicts!r})"

Expand Down Expand Up @@ -1991,16 +1962,6 @@ def cache_control_property(key, empty, type):
)


def cache_property(key, empty, type):
warnings.warn(
"'cache_property' is renamed to 'cache_control_property'. The"
" old name is deprecated and will be removed in Werkzeug 2.1.",
DeprecationWarning,
stacklevel=2,
)
return cache_control_property(key, empty, type)


class _CacheControl(UpdateDictMixin, dict):
"""Subclass of a dict that stores values for a Cache-Control header. It
has accessors for all the cache-control directives specified in RFC 2616.
Expand Down
Loading