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 os
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import warnings
|
||||||
|
|
||||||
import config as configuration
|
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.
|
: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
|
# nb. always show deprecation warnings when making config
|
||||||
if not factory:
|
with warnings.catch_warnings():
|
||||||
factory = WuttaConfig
|
warnings.filterwarnings("default", category=DeprecationWarning, module=r"^wutt")
|
||||||
config = factory(files, appname=appname, usedb=usedb, preferdb=preferdb, **kwargs)
|
|
||||||
|
|
||||||
# maybe extend config object
|
# collect file paths
|
||||||
if extend:
|
files = get_config_paths(
|
||||||
if not extension_entry_points:
|
files=files,
|
||||||
# nb. must not use appname here, entry points must be
|
plus_files=plus_files,
|
||||||
# consistent regardless of appname
|
appname=appname,
|
||||||
extension_entry_points = "wutta.config.extensions"
|
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
|
# make config object
|
||||||
# TODO: maybe let config disable some extensions?
|
if not factory:
|
||||||
extensions = load_entry_points(extension_entry_points)
|
factory = WuttaConfig
|
||||||
extensions = [ext() for ext in extensions.values()]
|
config = factory(
|
||||||
for extension in extensions:
|
files, appname=appname, usedb=usedb, preferdb=preferdb, **kwargs
|
||||||
log.debug("applying config extension: %s", extension.key)
|
)
|
||||||
extension.configure(config)
|
|
||||||
|
|
||||||
# let extensions run startup hooks if needed
|
# maybe extend config object
|
||||||
for extension in extensions:
|
if extend:
|
||||||
extension.startup(config)
|
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
|
return config
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue