fix: show deprecation warnings by default for 'wutt*' packages
This commit is contained in:
parent
58cef0c9c2
commit
35af58bfb1
1 changed files with 45 additions and 31 deletions
|
|
@ -31,6 +31,7 @@ import logging.config
|
|||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import warnings
|
||||
|
||||
import config as configuration
|
||||
|
||||
|
|
@ -1020,41 +1021,54 @@ def make_config( # pylint: disable=too-many-arguments,too-many-positional-argum
|
|||
|
||||
:returns: The new config object.
|
||||
"""
|
||||
# collect file paths
|
||||
files = get_config_paths(
|
||||
files=files,
|
||||
plus_files=plus_files,
|
||||
appname=appname,
|
||||
env_files_name=env_files_name,
|
||||
env_plus_files_name=env_plus_files_name,
|
||||
env=env,
|
||||
default_files=default_files,
|
||||
winsvc=winsvc,
|
||||
)
|
||||
|
||||
# make config object
|
||||
if not factory:
|
||||
factory = WuttaConfig
|
||||
config = factory(files, appname=appname, usedb=usedb, preferdb=preferdb, **kwargs)
|
||||
# nb. always show deprecation warnings when making config
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings("default", category=DeprecationWarning, module=r"^wutt")
|
||||
|
||||
# maybe extend config object
|
||||
if extend:
|
||||
if not extension_entry_points:
|
||||
# nb. must not use appname here, entry points must be
|
||||
# consistent regardless of appname
|
||||
extension_entry_points = "wutta.config.extensions"
|
||||
# collect file paths
|
||||
files = get_config_paths(
|
||||
files=files,
|
||||
plus_files=plus_files,
|
||||
appname=appname,
|
||||
env_files_name=env_files_name,
|
||||
env_plus_files_name=env_plus_files_name,
|
||||
env=env,
|
||||
default_files=default_files,
|
||||
winsvc=winsvc,
|
||||
)
|
||||
|
||||
# apply all registered extensions
|
||||
# TODO: maybe let config disable some extensions?
|
||||
extensions = load_entry_points(extension_entry_points)
|
||||
extensions = [ext() for ext in extensions.values()]
|
||||
for extension in extensions:
|
||||
log.debug("applying config extension: %s", extension.key)
|
||||
extension.configure(config)
|
||||
# make config object
|
||||
if not factory:
|
||||
factory = WuttaConfig
|
||||
config = factory(
|
||||
files, appname=appname, usedb=usedb, preferdb=preferdb, **kwargs
|
||||
)
|
||||
|
||||
# let extensions run startup hooks if needed
|
||||
for extension in extensions:
|
||||
extension.startup(config)
|
||||
# maybe extend config object
|
||||
if extend:
|
||||
if not extension_entry_points:
|
||||
# nb. must not use appname here, entry points must be
|
||||
# consistent regardless of appname
|
||||
extension_entry_points = "wutta.config.extensions"
|
||||
|
||||
# apply all registered extensions
|
||||
# TODO: maybe let config disable some extensions?
|
||||
extensions = load_entry_points(extension_entry_points)
|
||||
extensions = [ext() for ext in extensions.values()]
|
||||
for extension in extensions:
|
||||
log.debug("applying config extension: %s", extension.key)
|
||||
extension.configure(config)
|
||||
|
||||
# let extensions run startup hooks if needed
|
||||
for extension in extensions:
|
||||
extension.startup(config)
|
||||
|
||||
# maybe show deprecation warnings from now on
|
||||
if config.get_bool(
|
||||
f"{config.appname}.show_deprecation_warnings", usedb=False, default=True
|
||||
):
|
||||
warnings.filterwarnings("default", category=DeprecationWarning, module=r"^wutt")
|
||||
|
||||
return config
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue