Skip to content
Myr

Merge pull request #4667 from pallets/remove-deprecated-code

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Remove deprecated code

authored by David Lord · committed by GitHub · parents 96d39c8, c2810ff · Browse files · 3 files+16 added−90 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+16 added−90 removed

  • other:+16 added−90 removed

3 files+16 added−90 removed

modified:src/flask/ctx.py-26 removed
325 unmodified lines
326 # object. These will be called before the regular "after_request"327 # functions.328 self._after_request_functions: t.List[ft.AfterRequestCallable] = []329330 @property331 def g(self) -> _AppCtxGlobals:332 import warnings333334 warnings.warn(335 "Accessing 'g' on the request context is deprecated and"336 " will be removed in Flask 2.2. Access `g` directly or from"337 "the application context instead.",338 DeprecationWarning,339 stacklevel=2,340 )341 return _app_ctx_stack.top.g342343 @g.setter344 def g(self, value: _AppCtxGlobals) -> None:345 import warnings346347 warnings.warn(348 "Setting 'g' on the request context is deprecated and"349 " will be removed in Flask 2.2. Set it on the application"350 " context instead.",351 DeprecationWarning,352 stacklevel=2,353 )354 _app_ctx_stack.top.g = value355330 def copy(self) -> "RequestContext":331 """Creates a copy of this request context with the same request object.332 This can be used to move a request context to a different greenlet.333 Because the actual request object is the same this cannot be used to
123 unmodified lines
modified:src/flask/helpers.py+6 added-64 removed
1 unmodified line
2import pkgutil3import socket4import sys5import typing as t6import warnings6from datetime import datetime7from functools import lru_cache8from functools import update_wrapper9from threading import RLock
378 unmodified lines
388 return [x[1] for x in flashes]389 return flashes390391393def _prepare_send_file_kwargs(394 download_name: t.Optional[str] = None,395 attachment_filename: t.Optional[str] = None,396 etag: t.Optional[t.Union[bool, str]] = None,397 add_etags: t.Optional[t.Union[bool]] = None,398 max_age: t.Optional[399 t.Union[int, t.Callable[[t.Optional[str]], t.Optional[int]]]400 ] = None,401 cache_timeout: t.Optional[int] = None,402 **kwargs: t.Any,403) -> t.Dict[str, t.Any]:404 if attachment_filename is not None:405 warnings.warn(406 "The 'attachment_filename' parameter has been renamed to"407 " 'download_name'. The old name will be removed in Flask"408 " 2.2.",409 DeprecationWarning,410 stacklevel=3,411 )412 download_name = attachment_filename392def _prepare_send_file_kwargs(**kwargs: t.Any) -> t.Dict[str, t.Any]:393 if kwargs.get("max_age") is None:394 kwargs["max_age"] = current_app.get_send_file_max_age395414 if cache_timeout is not None:415 warnings.warn(416 "The 'cache_timeout' parameter has been renamed to"417 " 'max_age'. The old name will be removed in Flask 2.2.",418 DeprecationWarning,419 stacklevel=3,420 )421 max_age = cache_timeout422423 if add_etags is not None:424 warnings.warn(425 "The 'add_etags' parameter has been renamed to 'etag'. The"426 " old name will be removed in Flask 2.2.",427 DeprecationWarning,428 stacklevel=3,429 )430 etag = add_etags431432 if max_age is None:433 max_age = current_app.get_send_file_max_age434396 kwargs.update(397 environ=request.environ,437 download_name=download_name,438 etag=etag,439 max_age=max_age,398 use_x_sendfile=current_app.use_x_sendfile,399 response_class=current_app.response_class,400 _root_path=current_app.root_path, # type: ignore401 )
4 unmodified lines
406 path_or_file: t.Union[os.PathLike, str, t.BinaryIO],407 mimetype: t.Optional[str] = None,408 as_attachment: bool = False,409 download_name: t.Optional[str] = None,452 attachment_filename: t.Optional[str] = None,410 conditional: bool = True,411 etag: t.Union[bool, str] = True,455 add_etags: t.Optional[bool] = None,412 last_modified: t.Optional[t.Union[datetime, int, float]] = None,413 max_age: t.Optional[414 t.Union[int, t.Callable[[t.Optional[str]], t.Optional[int]]]415 ] = None,460 cache_timeout: t.Optional[int] = None,461):416) -> "Response":417 """Send the contents of a file to the client.418419 The first argument can be a file path or a file-like object. Paths420 are preferred in most cases because Werkzeug can manage the file and
93 unmodified lines
514 parameters were added. The default behavior is to add etags.515516 .. versionadded:: 0.2517 """563 return werkzeug.utils.send_file(518 return werkzeug.utils.send_file( # type: ignore[return-value]519 **_prepare_send_file_kwargs(520 path_or_file=path_or_file,521 environ=request.environ,522 mimetype=mimetype,523 as_attachment=as_attachment,524 download_name=download_name,570 attachment_filename=attachment_filename,525 conditional=conditional,526 etag=etag,573 add_etags=add_etags,527 last_modified=last_modified,528 max_age=max_age,576 cache_timeout=cache_timeout,529 )530 )531532533def send_from_directory(534 directory: t.Union[os.PathLike, str],535 path: t.Union[os.PathLike, str],584 filename: t.Optional[str] = None,536 **kwargs: t.Any,537) -> "Response":538 """Send a file from within a directory using :func:`send_file`.539
27 unmodified lines
567 pass some Flask-specific arguments.568569 .. versionadded:: 0.5570 """620 if filename is not None:621 warnings.warn(622 "The 'filename' parameter has been renamed to 'path'. The"623 " old name will be removed in Flask 2.2.",624 DeprecationWarning,625 stacklevel=2,626 )627 path = filename628629 return werkzeug.utils.send_from_directory( # type: ignore571 return werkzeug.utils.send_from_directory( # type: ignore[return-value]572 directory, path, **_prepare_send_file_kwargs(**kwargs)573 )574575
111 unmodified lines
modified:CHANGES.rst+10 added
3 unmodified lines
4-------------56Unreleased78- Remove previously deprecated code. :pr:`4337`910 - Old names for some ``send_file`` parameters have been removed.11 ``download_name`` replaces ``attachment_filename``, ``max_age``12 replaces ``cache_timeout``, and ``etag`` replaces ``add_etags``.13 Additionally, ``path`` replaces ``filename`` in14 ``send_from_directory``.15 - The ``RequestContext.g`` property returning ``AppContext.g`` is16 removed.1718- Add new customization points to the ``Flask`` app object for many19 previously global behaviors.2021 - ``flask.url_for`` will call ``app.url_for``. :issue:`4568`
1340 unmodified lines