Merge pull request #4081 from pallets/config-json
re-add deprecated `Config.from_json` method
This commit is contained in:
commit
69e6d59ac8
2 changed files with 27 additions and 0 deletions
|
|
@ -23,6 +23,8 @@ Unreleased
|
|||
- Roll back a change to the order that URL matching was done. The
|
||||
URL is again matched after the session is loaded, so the session is
|
||||
available in custom URL converters. :issue:`4053`
|
||||
- Re-add deprecated ``Config.from_json``, which was accidentally
|
||||
removed early. :issue:`4078`
|
||||
|
||||
|
||||
Version 2.0.0
|
||||
|
|
|
|||
|
|
@ -202,6 +202,31 @@ class Config(dict):
|
|||
|
||||
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.
|
||||
|
||||
.. 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(
|
||||
self, mapping: t.Optional[t.Mapping[str, t.Any]] = None, **kwargs: t.Any
|
||||
) -> bool:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue