From f702d3efffda796ba1d7747b64cadb732fa8a274 Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Mon, 2 Dec 2024 01:33:06 -0800 Subject: [PATCH] Fix _Opt deprecation warnings (#313) * Fix _Opt deprecation warnings * Update extension.py --------- Co-authored-by: Manuel Kaufmann --- hoverxref/extension.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hoverxref/extension.py b/hoverxref/extension.py index 45fc03c..5d54d50 100644 --- a/hoverxref/extension.py +++ b/hoverxref/extension.py @@ -61,10 +61,10 @@ def copy_asset_files(app, exception): if exception is None: # build succeeded context = {} - for attr in app.config.values: + for attr, opt in app.config.values.items(): if attr.startswith('hoverxref_'): # First, add the default values to the context - context[attr] = app.config.values[attr][0] + context[attr] = opt.default if hasattr(opt, "default") else opt[0] for attr in dir(app.config): if attr.startswith('hoverxref_'): @@ -264,7 +264,8 @@ def setup_theme(app, exception): """ css_file = None theme = app.config.html_theme - default, rebuild, types = app.config.values.get('hoverxref_modal_class') + opt = app.config.values['hoverxref_modal_class'] + default = opt.default if hasattr(opt, "default") else opt[0] if theme == 'sphinx_material': if app.config.hoverxref_modal_class == default: app.config.hoverxref_modal_class = 'md-typeset' @@ -296,8 +297,8 @@ def setup_assets_policy(app, exception): def deprecated_configs_warning(app, exception): """Log warning message if old configs are used.""" - default, rebuild, types = app.config.values.get('hoverxref_tooltip_api_host') - if app.config.hoverxref_tooltip_api_host != default: + opt = app.config.values['hoverxref_tooltip_api_host'] + if app.config.hoverxref_tooltip_api_host != (opt.default if hasattr(opt, "default") else opt[0]): message = '"hoverxref_tooltip_api_host" is deprecated and replaced by "hoverxref_api_host".' logger.warning(message) app.config.hoverxref_api_host = app.config.hoverxref_tooltip_api_host