forked from orbit-oss/flask
remove previously deprecated code
This commit is contained in:
parent
604de4b1dc
commit
6650764e97
16 changed files with 81 additions and 946 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import json
|
||||
import os
|
||||
import typing as t
|
||||
from collections import defaultdict
|
||||
|
|
@ -15,9 +14,6 @@ if t.TYPE_CHECKING: # pragma: no cover
|
|||
|
||||
DeferredSetupFunction = t.Callable[["BlueprintSetupState"], t.Callable]
|
||||
T_after_request = t.TypeVar("T_after_request", bound=ft.AfterRequestCallable)
|
||||
T_before_first_request = t.TypeVar(
|
||||
"T_before_first_request", bound=ft.BeforeFirstRequestCallable
|
||||
)
|
||||
T_before_request = t.TypeVar("T_before_request", bound=ft.BeforeRequestCallable)
|
||||
T_error_handler = t.TypeVar("T_error_handler", bound=ft.ErrorHandlerCallable)
|
||||
T_teardown = t.TypeVar("T_teardown", bound=ft.TeardownCallable)
|
||||
|
|
@ -173,77 +169,6 @@ class Blueprint(Scaffold):
|
|||
|
||||
_got_registered_once = False
|
||||
|
||||
_json_encoder: t.Union[t.Type[json.JSONEncoder], None] = None
|
||||
_json_decoder: t.Union[t.Type[json.JSONDecoder], None] = None
|
||||
|
||||
@property
|
||||
def json_encoder(
|
||||
self,
|
||||
) -> t.Union[t.Type[json.JSONEncoder], None]:
|
||||
"""Blueprint-local JSON encoder class to use. Set to ``None`` to use the app's.
|
||||
|
||||
.. deprecated:: 2.2
|
||||
Will be removed in Flask 2.3. Customize
|
||||
:attr:`json_provider_class` instead.
|
||||
|
||||
.. versionadded:: 0.10
|
||||
"""
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"'bp.json_encoder' is deprecated and will be removed in Flask 2.3."
|
||||
" Customize 'app.json_provider_class' or 'app.json' instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self._json_encoder
|
||||
|
||||
@json_encoder.setter
|
||||
def json_encoder(self, value: t.Union[t.Type[json.JSONEncoder], None]) -> None:
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"'bp.json_encoder' is deprecated and will be removed in Flask 2.3."
|
||||
" Customize 'app.json_provider_class' or 'app.json' instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
self._json_encoder = value
|
||||
|
||||
@property
|
||||
def json_decoder(
|
||||
self,
|
||||
) -> t.Union[t.Type[json.JSONDecoder], None]:
|
||||
"""Blueprint-local JSON decoder class to use. Set to ``None`` to use the app's.
|
||||
|
||||
.. deprecated:: 2.2
|
||||
Will be removed in Flask 2.3. Customize
|
||||
:attr:`json_provider_class` instead.
|
||||
|
||||
.. versionadded:: 0.10
|
||||
"""
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"'bp.json_decoder' is deprecated and will be removed in Flask 2.3."
|
||||
" Customize 'app.json_provider_class' or 'app.json' instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self._json_decoder
|
||||
|
||||
@json_decoder.setter
|
||||
def json_decoder(self, value: t.Union[t.Type[json.JSONDecoder], None]) -> None:
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"'bp.json_decoder' is deprecated and will be removed in Flask 2.3."
|
||||
" Customize 'app.json_provider_class' or 'app.json' instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
self._json_decoder = value
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
|
|
@ -361,6 +286,10 @@ class Blueprint(Scaffold):
|
|||
.. versionchanged:: 2.3
|
||||
Nested blueprints now correctly apply subdomains.
|
||||
|
||||
.. versionchanged:: 2.1
|
||||
Registering the same blueprint with the same name multiple
|
||||
times is an error.
|
||||
|
||||
.. versionchanged:: 2.0.1
|
||||
Nested blueprints are registered with their dotted name.
|
||||
This allows different blueprints with the same name to be
|
||||
|
|
@ -371,10 +300,6 @@ class Blueprint(Scaffold):
|
|||
name the blueprint is registered with. This allows the same
|
||||
blueprint to be registered multiple times with unique names
|
||||
for ``url_for``.
|
||||
|
||||
.. versionchanged:: 2.0.1
|
||||
Registering the same blueprint with the same name multiple
|
||||
times is deprecated and will become an error in Flask 2.1.
|
||||
"""
|
||||
name_prefix = options.get("name_prefix", "")
|
||||
self_name = options.get("name", self.name)
|
||||
|
|
@ -634,29 +559,6 @@ class Blueprint(Scaffold):
|
|||
)
|
||||
return f
|
||||
|
||||
@setupmethod
|
||||
def before_app_first_request(
|
||||
self, f: T_before_first_request
|
||||
) -> T_before_first_request:
|
||||
"""Register a function to run before the first request to the application is
|
||||
handled by the worker. Equivalent to :meth:`.Flask.before_first_request`.
|
||||
|
||||
.. deprecated:: 2.2
|
||||
Will be removed in Flask 2.3. Run setup code when creating
|
||||
the application instead.
|
||||
"""
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"'before_app_first_request' is deprecated and will be"
|
||||
" removed in Flask 2.3. Use 'record_once' instead to run"
|
||||
" setup code when registering the blueprint.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
self.record_once(lambda s: s.app.before_first_request_funcs.append(f))
|
||||
return f
|
||||
|
||||
@setupmethod
|
||||
def after_app_request(self, f: T_after_request) -> T_after_request:
|
||||
"""Like :meth:`after_request`, but after every request, not only those handled
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue