remove deprecated config.from_json

This commit is contained in:
David Lord 2021-11-12 06:50:57 -08:00
parent e21e003f62
commit 2bd7aed1a4
No known key found for this signature in database
GPG Key ID: 7A1C87E3F5BC42A8
2 changed files with 5 additions and 26 deletions

View File

@ -10,6 +10,8 @@ Unreleased
- Remove previously deprecated code. :pr:`4337` - Remove previously deprecated code. :pr:`4337`
- The CLI does not pass ``script_info`` to app factory functions. - The CLI does not pass ``script_info`` to app factory functions.
- ``config.from_json`` is replaced by
``config.from_file(name, load=json.load)``.
Version 2.0.2 Version 2.0.2

View File

@ -176,6 +176,9 @@ class Config(dict):
.. code-block:: python .. code-block:: python
import json
app.config.from_file("config.json", load=json.load)
import toml import toml
app.config.from_file("config.toml", load=toml.load) app.config.from_file("config.toml", load=toml.load)
@ -204,32 +207,6 @@ class Config(dict):
return self.from_mapping(obj) return self.from_mapping(obj)
def from_json(self, filename: str, silent: bool = False) -> bool:
"""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.
:return: ``True`` if the file was loaded successfully.
.. deprecated:: 2.0.0
Will be removed in Flask 2.1. Use :meth:`from_file` instead.
This was removed early in 2.0.0, was added back in 2.0.1.
.. versionadded:: 0.11
"""
import warnings
from . import json
warnings.warn(
"'from_json' is deprecated and will be removed in Flask"
" 2.1. Use 'from_file(path, json.load)' instead.",
DeprecationWarning,
stacklevel=2,
)
return self.from_file(filename, json.load, silent=silent)
def from_mapping( def from_mapping(
self, mapping: t.Optional[t.Mapping[str, t.Any]] = None, **kwargs: t.Any self, mapping: t.Optional[t.Mapping[str, t.Any]] = None, **kwargs: t.Any
) -> bool: ) -> bool: