Skip to content

Commit f8fb51d

Browse files
committed
fix _Opt deprecation warning
closes readthedocs#234
1 parent 3616f22 commit f8fb51d

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

notfound/extension.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import html
2-
import docutils.nodes
32
import os
43
import warnings
54

5+
import docutils.nodes
66
import sphinx
77
from sphinx.environment.collectors import EnvironmentCollector
88
from sphinx.errors import ExtensionError
@@ -13,7 +13,6 @@
1313

1414
class BaseURIError(ExtensionError):
1515
"""Exception for malformed base URI."""
16-
pass
1716

1817

1918
# https://www.sphinx-doc.org/en/stable/extdev/appapi.html#event-html-collect-pages
@@ -167,7 +166,11 @@ def toctree(*args, **kwargs):
167166
# We have to overwrite them here to use our own `pathto` function.
168167
# The code is borrowed exactly from Sphinx 7.2.2, there is no changes.
169168
if sphinx.version_info >= (7, 2):
170-
from sphinx.builders.html._assets import _CascadingStyleSheet, _file_checksum, _JavaScript
169+
from sphinx.builders.html._assets import (
170+
_CascadingStyleSheet,
171+
_file_checksum,
172+
_JavaScript,
173+
)
171174

172175
outdir = app.outdir
173176

@@ -266,14 +269,17 @@ def validate_configs(app, *args, **kwargs):
266269
267270
Shows a warning if one of the configs is not valid.
268271
"""
269-
default, rebuild, types = app.config.values.get('notfound_urls_prefix')
270-
if app.config.notfound_urls_prefix != default:
271-
if app.config.notfound_urls_prefix and not all([
272-
app.config.notfound_urls_prefix.startswith('/'),
273-
app.config.notfound_urls_prefix.endswith('/'),
274-
]):
275-
message = 'notfound_urls_prefix should start and end with "/" (slash)'
276-
warnings.warn(message, UserWarning, stacklevel=2)
272+
default = app.config.values.get("notfound_urls_prefix").default
273+
notfound_urls_prefix = app.config.notfound_urls_prefix
274+
if (
275+
notfound_urls_prefix != default
276+
and notfound_urls_prefix
277+
and not (
278+
notfound_urls_prefix.startswith("/") or notfound_urls_prefix.endswith("/")
279+
)
280+
):
281+
message = 'notfound_urls_prefix should start and end with "/" (slash)'
282+
warnings.warn(message, UserWarning, stacklevel=2)
277283

278284

279285
def setup(app):

0 commit comments

Comments
 (0)