remove deprecated code

This commit is contained in:
David Lord 2020-04-03 17:34:32 -07:00
parent a0a61acdec
commit 1263d3bd14
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
9 changed files with 0 additions and 198 deletions

View file

@ -17,7 +17,6 @@ from werkzeug.exceptions import abort
from werkzeug.utils import redirect from werkzeug.utils import redirect
from . import json from . import json
from ._compat import json_available
from .app import Flask from .app import Flask
from .app import Request from .app import Request
from .app import Response from .app import Response

View file

@ -113,33 +113,3 @@ except ImportError:
# https://www.python.org/dev/peps/pep-0519/#backwards-compatibility # https://www.python.org/dev/peps/pep-0519/#backwards-compatibility
def fspath(path): def fspath(path):
return path.__fspath__() if hasattr(path, "__fspath__") else path return path.__fspath__() if hasattr(path, "__fspath__") else path
class _DeprecatedBool(object):
def __init__(self, name, version, value):
self.message = "'{}' is deprecated and will be removed in version {}.".format(
name, version
)
self.value = value
def _warn(self):
import warnings
warnings.warn(self.message, DeprecationWarning, stacklevel=2)
def __eq__(self, other):
self._warn()
return other == self.value
def __ne__(self, other):
self._warn()
return other != self.value
def __bool__(self):
self._warn()
return self.value
__nonzero__ = __bool__
json_available = _DeprecatedBool("flask.json_available", "2.0.0", True)

View file

@ -10,7 +10,6 @@
""" """
import os import os
import sys import sys
import warnings
from datetime import timedelta from datetime import timedelta
from functools import update_wrapper from functools import update_wrapper
from itertools import chain from itertools import chain
@ -1066,70 +1065,6 @@ class Flask(_PackageBoundObject):
return cls(self, **kwargs) return cls(self, **kwargs)
def open_session(self, request):
"""Creates or opens a new session. Default implementation stores all
session data in a signed cookie. This requires that the
:attr:`secret_key` is set. Instead of overriding this method
we recommend replacing the :class:`session_interface`.
.. deprecated: 1.0
Will be removed in 2.0. Use
``session_interface.open_session`` instead.
:param request: an instance of :attr:`request_class`.
"""
warnings.warn(
DeprecationWarning(
'"open_session" is deprecated and will be removed in'
' 2.0. Use "session_interface.open_session" instead.'
)
)
return self.session_interface.open_session(self, request)
def save_session(self, session, response):
"""Saves the session if it needs updates. For the default
implementation, check :meth:`open_session`. Instead of overriding this
method we recommend replacing the :class:`session_interface`.
.. deprecated: 1.0
Will be removed in 2.0. Use
``session_interface.save_session`` instead.
:param session: the session to be saved (a
:class:`~werkzeug.contrib.securecookie.SecureCookie`
object)
:param response: an instance of :attr:`response_class`
"""
warnings.warn(
DeprecationWarning(
'"save_session" is deprecated and will be removed in'
' 2.0. Use "session_interface.save_session" instead.'
)
)
return self.session_interface.save_session(self, session, response)
def make_null_session(self):
"""Creates a new instance of a missing session. Instead of overriding
this method we recommend replacing the :class:`session_interface`.
.. deprecated: 1.0
Will be removed in 2.0. Use
``session_interface.make_null_session`` instead.
.. versionadded:: 0.7
"""
warnings.warn(
DeprecationWarning(
'"make_null_session" is deprecated and will be removed'
' in 2.0. Use "session_interface.make_null_session"'
" instead."
)
)
return self.session_interface.make_null_session(self)
@setupmethod @setupmethod
def register_blueprint(self, blueprint, **options): def register_blueprint(self, blueprint, **options):
"""Register a :class:`~flask.Blueprint` on the application. Keyword """Register a :class:`~flask.Blueprint` on the application. Keyword

View file

@ -11,7 +11,6 @@
import errno import errno
import os import os
import types import types
import warnings
from werkzeug.utils import import_string from werkzeug.utils import import_string
@ -210,29 +209,6 @@ class Config(dict):
return self.from_mapping(obj) return self.from_mapping(obj)
def from_json(self, filename, silent=False):
"""Update the values in the config from a JSON file. The loaded
data is passed to the :meth:`from_mapping` method.
:param filename: The path to the JSON file. This can be an
absolute path or relative to the config root path.
:param silent: Ignore the file if it doesn't exist.
.. deprecated:: 2.0
Use :meth:`from_file` with :meth:`json.load` instead.
.. versionadded:: 0.11
"""
warnings.warn(
"'from_json' is deprecated and will be removed in 2.0."
" Use 'from_file(filename, load=json.load)' instead.",
DeprecationWarning,
stacklevel=2,
)
from .json import load
return self.from_file(filename, load, silent=silent)
def from_mapping(self, *mapping, **kwargs): def from_mapping(self, *mapping, **kwargs):
"""Updates the config like :meth:`update` ignoring items with non-upper """Updates the config like :meth:`update` ignoring items with non-upper
keys. keys.

View file

@ -10,7 +10,6 @@ from __future__ import absolute_import
import logging import logging
import sys import sys
import warnings
from werkzeug.local import LocalProxy from werkzeug.local import LocalProxy
@ -57,20 +56,6 @@ default_handler.setFormatter(
) )
def _has_config(logger):
"""Decide if a logger has direct configuration applied by checking
its properties against the defaults.
:param logger: The :class:`~logging.Logger` to inspect.
"""
return (
logger.level != logging.NOTSET
or logger.handlers
or logger.filters
or not logger.propagate
)
def create_logger(app): def create_logger(app):
"""Get the Flask app's logger and configure it if needed. """Get the Flask app's logger and configure it if needed.
@ -86,20 +71,6 @@ def create_logger(app):
""" """
logger = logging.getLogger(app.name) logger = logging.getLogger(app.name)
# 1.1.0 changes name of logger, warn if config is detected for old
# name and not new name
for old_name in ("flask.app", "flask"):
old_logger = logging.getLogger(old_name)
if _has_config(old_logger) and not _has_config(logger):
warnings.warn(
"'app.logger' is named '{name}' for this application,"
" but configuration was found for '{old_name}', which"
" no longer has an effect. The logging configuration"
" should be moved to '{name}'.".format(name=app.name, old_name=old_name)
)
break
if app.debug and not logger.level: if app.debug and not logger.level:
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)

View file

@ -9,7 +9,6 @@
:copyright: 2010 Pallets :copyright: 2010 Pallets
:license: BSD-3-Clause :license: BSD-3-Clause
""" """
import warnings
from contextlib import contextmanager from contextlib import contextmanager
import werkzeug.test import werkzeug.test
@ -95,23 +94,6 @@ class EnvironBuilder(werkzeug.test.EnvironBuilder):
return json_dumps(obj, **kwargs) return json_dumps(obj, **kwargs)
def make_test_environ_builder(*args, **kwargs):
"""Create a :class:`flask.testing.EnvironBuilder`.
.. deprecated: 1.1
Will be removed in 2.0. Construct
``flask.testing.EnvironBuilder`` directly instead.
"""
warnings.warn(
DeprecationWarning(
'"make_test_environ_builder()" is deprecated and will be'
' removed in 2.0. Construct "flask.testing.EnvironBuilder"'
" directly instead."
)
)
return EnvironBuilder(*args, **kwargs)
class FlaskClient(Client): class FlaskClient(Client):
"""Works like a regular Werkzeug test client but has some knowledge about """Works like a regular Werkzeug test client but has some knowledge about
how Flask works to defer the cleanup of the request context stack to the how Flask works to defer the cleanup of the request context stack to the

View file

@ -1,12 +0,0 @@
import pytest
from flask import json_available
def test_json_available():
with pytest.deprecated_call() as rec:
assert json_available
assert json_available == True # noqa E712
assert json_available != False # noqa E712
assert len(rec.list) == 3

View file

@ -104,12 +104,3 @@ def test_log_view_exception(app, client):
err = stream.getvalue() err = stream.getvalue()
assert "Exception on / [GET]" in err assert "Exception on / [GET]" in err
assert "Exception: test" in err assert "Exception: test" in err
def test_warn_old_config(app, request):
old_logger = logging.getLogger("flask.app")
old_logger.setLevel(logging.DEBUG)
request.addfinalizer(lambda: old_logger.setLevel(logging.NOTSET))
with pytest.warns(UserWarning):
assert app.logger.getEffectiveLevel() == logging.WARNING

View file

@ -19,7 +19,6 @@ from flask.cli import ScriptInfo
from flask.json import jsonify from flask.json import jsonify
from flask.testing import EnvironBuilder from flask.testing import EnvironBuilder
from flask.testing import FlaskCliRunner from flask.testing import FlaskCliRunner
from flask.testing import make_test_environ_builder
try: try:
import blinker import blinker
@ -121,15 +120,6 @@ def test_path_is_url(app):
assert eb.path == "/" assert eb.path == "/"
def test_make_test_environ_builder(app):
with pytest.deprecated_call():
eb = make_test_environ_builder(app, "https://example.com/")
assert eb.url_scheme == "https"
assert eb.host == "example.com"
assert eb.script_root == ""
assert eb.path == "/"
def test_environbuilder_json_dumps(app): def test_environbuilder_json_dumps(app):
"""EnvironBuilder.json_dumps() takes settings from the app.""" """EnvironBuilder.json_dumps() takes settings from the app."""
app.config["JSON_AS_ASCII"] = False app.config["JSON_AS_ASCII"] = False