remove deprecated code (#5223)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by GitHub · parents 6a12b19, 04994df · Browse files · 7 files·+3 added−225 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+3 added−225 removed
- other:+3 added−225 removed
Provenance
- Commit
0e0e8dd- Tree
69301e3- Author
David Lord <davidism@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
6a12b19- Parent 2
04994df
7 files changed+3 added−225 removed
modified:docs/api.rst-5 removed
517 unmodified lines518 message_flashed.connect(record, app)519 520 .. versionadded:: 0.10521 522-.. data:: signals.signals_available522 524- .. deprecated:: 2.3525- Will be removed in Flask 2.4. Signals are always available526-527-523 Class-Based Views524 -----------------525 526 .. versionadded:: 0.7191 unmodified linesmodified:src/flask/__init__.py-61 removed
37 unmodified lines38 from .templating import stream_template as stream_template39 from .templating import stream_template_string as stream_template_string40 41 __version__ = "3.0.0.dev"42-43-44-def __getattr__(name):45- if name == "_app_ctx_stack":46- import warnings47- from .globals import __app_ctx_stack48-49- warnings.warn(50- "'_app_ctx_stack' is deprecated and will be removed in Flask 2.4.",51- DeprecationWarning,52- stacklevel=2,53- )54- return __app_ctx_stack55-56- if name == "_request_ctx_stack":57- import warnings58- from .globals import __request_ctx_stack59-60- warnings.warn(61- "'_request_ctx_stack' is deprecated and will be removed in Flask 2.4.",62- DeprecationWarning,63- stacklevel=2,64- )65- return __request_ctx_stack66-67- if name == "escape":68- import warnings69- from markupsafe import escape70-71- warnings.warn(72- "'flask.escape' is deprecated and will be removed in Flask 2.4. Import"73- " 'markupsafe.escape' instead.",74- DeprecationWarning,75- stacklevel=2,76- )77- return escape78-79- if name == "Markup":80- import warnings81- from markupsafe import Markup82-83- warnings.warn(84- "'flask.Markup' is deprecated and will be removed in Flask 2.4. Import"85- " 'markupsafe.Markup' instead.",86- DeprecationWarning,87- stacklevel=2,88- )89- return Markup90-91- if name == "signals_available":92- import warnings93-94- warnings.warn(95- "'signals_available' is deprecated and will be removed in Flask 2.4."96- " Signals are always available",97- DeprecationWarning,98- stacklevel=2,99- )100- return True101-102- raise AttributeError(name)modified:src/flask/app.py-19 removed
570 unmodified lines571 effect.572 """573 return self.create_jinja_environment()574 575- @property576- def got_first_request(self) -> bool:577- """This attribute is set to ``True`` if the application started578- handling the first request.579-580- .. deprecated:: 2.3581- Will be removed in Flask 2.4.582-583- .. versionadded:: 0.8584- """585- import warnings586-587- warnings.warn(588- "'got_first_request' is deprecated and will be removed in Flask 2.4.",589- DeprecationWarning,590- stacklevel=2,591- )592- return self._got_first_request593-575 def make_config(self, instance_relative: bool = False) -> Config:576 """Used to create the config attribute by the Flask constructor.577 The `instance_relative` parameter is passed in from the constructor578 of Flask (there named `instance_relative_config`) and indicates if1616 unmodified linesmodified:src/flask/globals.py-45 removed
12 unmodified lines13 from .sessions import SessionMixin14 from .wrappers import Request15 16 17-class _FakeStack:18- def __init__(self, name: str, cv: ContextVar[t.Any]) -> None:19- self.name = name20- self.cv = cv21-22- @property23- def top(self) -> t.Any | None:24- import warnings25-26- warnings.warn(27- f"'_{self.name}_ctx_stack' is deprecated and will be removed in Flask 2.4."28- f" Use 'g' to store data, or '{self.name}_ctx' to access the current"29- " context.",30- DeprecationWarning,31- stacklevel=2,32- )33- return self.cv.get(None)34-35-17 _no_app_msg = """\18 Working outside of application context.19 20 This typically means that you attempted to use functionality that needed21 the current application. To solve this, set up an application context22 with app.app_context(). See the documentation for more information.\23 """24 _cv_app: ContextVar[AppContext] = ContextVar("flask.app_ctx")44-__app_ctx_stack = _FakeStack("app", _cv_app)25 app_ctx: AppContext = LocalProxy( # type: ignore[assignment]26 _cv_app, unbound_message=_no_app_msg27 )28 current_app: Flask = LocalProxy( # type: ignore[assignment]10 unmodified lines39 an active HTTP request. Consult the documentation on testing for40 information about how to avoid this problem.\41 """42 _cv_request: ContextVar[RequestContext] = ContextVar("flask.request_ctx")63-__request_ctx_stack = _FakeStack("request", _cv_request)43 request_ctx: RequestContext = LocalProxy( # type: ignore[assignment]44 _cv_request, unbound_message=_no_req_msg45 )46 request: Request = LocalProxy( # type: ignore[assignment]1 unmodified line48 )49 session: SessionMixin = LocalProxy( # type: ignore[assignment]50 _cv_request, "session", unbound_message=_no_req_msg51 )73-74-75-def __getattr__(name: str) -> t.Any:76- if name == "_app_ctx_stack":77- import warnings78-79- warnings.warn(80- "'_app_ctx_stack' is deprecated and will be removed in Flask 2.4.",81- DeprecationWarning,82- stacklevel=2,83- )84- return __app_ctx_stack85-86- if name == "_request_ctx_stack":87- import warnings88-89- warnings.warn(90- "'_request_ctx_stack' is deprecated and will be removed in Flask 2.4.",91- DeprecationWarning,92- stacklevel=2,93- )94- return __request_ctx_stack95-96- raise AttributeError(name)modified:src/flask/helpers.py+1 added-79 removed
1 from __future__ import annotations2 3 import importlib.util4 import os5-import socket5 import sys6 import typing as t8-import warnings7 from datetime import datetime8 from functools import lru_cache9 from functools import update_wrapper12-from threading import RLock10 11 import werkzeug.utils12 from werkzeug.exceptions import abort as _wz_abort13 from werkzeug.utils import redirect as _wz_redirect474 unmodified lines488 :meth:`Flask.get_send_file_max_age`.489 490 .. versionchanged:: 0.7491 MIME guessing and etag support for file-like objects was495- deprecated because it was unreliable. Pass a filename if you are492+ removed because it was unreliable. Pass a filename if you are493 able to, otherwise attach an etag yourself.494 495 .. versionchanged:: 0.5496 The ``add_etags``, ``cache_timeout`` and ``conditional``115 unmodified lines612 # filepath is import_name.py for a module, or __init__.py for a package.613 return os.path.dirname(os.path.abspath(filepath))614 615 619-class locked_cached_property(werkzeug.utils.cached_property):620- """A :func:`property` that is only evaluated once. Like621- :class:`werkzeug.utils.cached_property` except access uses a lock622- for thread safety.623-624- .. deprecated:: 2.3625- Will be removed in Flask 2.4. Use a lock inside the decorated function if626- locking is needed.627-628- .. versionchanged:: 2.0629- Inherits from Werkzeug's ``cached_property`` (and ``property``).630- """631-632- def __init__(633- self,634- fget: t.Callable[[t.Any], t.Any],635- name: str | None = None,636- doc: str | None = None,637- ) -> None:638- import warnings639-640- warnings.warn(641- "'locked_cached_property' is deprecated and will be removed in Flask 2.4."642- " Use a lock inside the decorated function if locking is needed.",643- DeprecationWarning,644- stacklevel=2,645- )646- super().__init__(fget, name=name, doc=doc)647- self.lock = RLock()648-649- def __get__(self, obj: object, type: type = None) -> t.Any: # type: ignore650- if obj is None:651- return self652-653- with self.lock:654- return super().__get__(obj, type=type)655-656- def __set__(self, obj: object, value: t.Any) -> None:657- with self.lock:658- super().__set__(obj, value)659-660- def __delete__(self, obj: object) -> None:661- with self.lock:662- super().__delete__(obj)663-664-665-def is_ip(value: str) -> bool:666- """Determine if the given string is an IP address.667-668- :param value: value to check669- :type value: str670-671- :return: True if string is an IP address672- :rtype: bool673-674- .. deprecated:: 2.3675- Will be removed in Flask 2.4.676- """677- warnings.warn(678- "The 'is_ip' function is deprecated and will be removed in Flask 2.4.",679- DeprecationWarning,680- stacklevel=2,681- )682-683- for family in (socket.AF_INET, socket.AF_INET6):684- try:685- socket.inet_pton(family, value)686- except OSError:687- pass688- else:689- return True690-691- return False692-693-616 @lru_cache(maxsize=None)617 def _split_blueprint_path(name: str) -> list[str]:618 out: list[str] = [name]619 4 unmodified linesmodified:src/flask/signals.py-16 removed
1 from __future__ import annotations2 3-import typing as t4-import warnings5-3 from blinker import Namespace4 5 # This namespace is only for signals provided by Flask itself.6 _signals = Namespace()7 unmodified lines14 appcontext_tearing_down = _signals.signal("appcontext-tearing-down")15 appcontext_pushed = _signals.signal("appcontext-pushed")16 appcontext_popped = _signals.signal("appcontext-popped")17 message_flashed = _signals.signal("message-flashed")21-22-23-def __getattr__(name: str) -> t.Any:24- if name == "signals_available":25- warnings.warn(26- "The 'signals_available' attribute is deprecated and will be removed in"27- " Flask 2.4. Signals are always available.",28- DeprecationWarning,29- stacklevel=2,30- )31- return True32-33- raise AttributeError(name)modified:CHANGES.rst+2 added
1 unmodified line2 -------------3 4 Unreleased5 6+- Remove previously deprecated code. :pr:`5223`7 8+9 Version 2.3.310 -------------11 12 Unreleased1512 unmodified lines