From 3d67c80808565f2718fc85e98a54922703594d3d Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com> Date: Thu, 10 Oct 2024 00:46:25 -0700 Subject: [PATCH 1/2] Fix _Opt deprecation warnings --- hoverxref/extension.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hoverxref/extension.py b/hoverxref/extension.py index 74d80ed..8042d06 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] = getattr(opt, "default", opt[0]) for attr in dir(app.config): if attr.startswith('hoverxref_'): @@ -277,7 +277,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 = getattr(opt, "default", opt[0]) if theme == 'sphinx_material': if app.config.hoverxref_modal_class == default: app.config.hoverxref_modal_class = 'md-typeset' @@ -309,8 +310,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 != getattr(opt, "default", 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 From 34cd01bd17db661384b0ec25050b8b3fa4212a38 Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com> Date: Wed, 13 Nov 2024 10:12:57 -0800 Subject: [PATCH 2/2] Update extension.py --- hoverxref/extension.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hoverxref/extension.py b/hoverxref/extension.py index 8042d06..b928a3f 100644 --- a/hoverxref/extension.py +++ b/hoverxref/extension.py @@ -64,7 +64,7 @@ def copy_asset_files(app, exception): for attr, opt in app.config.values.items(): if attr.startswith('hoverxref_'): # First, add the default values to the context - context[attr] = getattr(opt, "default", opt[0]) + context[attr] = opt.default if hasattr(opt, "default") else opt[0] for attr in dir(app.config): if attr.startswith('hoverxref_'): @@ -278,7 +278,7 @@ def setup_theme(app, exception): css_file = None theme = app.config.html_theme opt = app.config.values['hoverxref_modal_class'] - default = getattr(opt, "default", opt[0]) + 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' @@ -311,7 +311,7 @@ def setup_assets_policy(app, exception): def deprecated_configs_warning(app, exception): """Log warning message if old configs are used.""" opt = app.config.values['hoverxref_tooltip_api_host'] - if app.config.hoverxref_tooltip_api_host != getattr(opt, "default", opt[0]): + 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