Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix _Opt deprecation warnings #313

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions hoverxref/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_'):
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down