You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix translator_setup: undefined default_translator_class for linkcheck builder (#2029)
The translator setup is called unconditionally to add the
HootstrapHTML5TransatorMixin. If no translators have been set explicitly
this falls back to `app.builder.default_translator_class`, which is
however not defined for the `linkcheck` builder (maybe others),
resulting in an attribute error:
```console
$ sphinx-build -T -b linkcheck <src> <dest>
<...>
Traceback (most recent call last):
File "/PATH/TO/venv/lib/python3.11/site-packages/sphinx/events.py", line 404, in emit
results.append(listener.handler(self.app, *args))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/PATH/TO/venv/lib/python3.11/site-packages/pydata_sphinx_theme/translator.py", line 88, in setup_translators
app.builder.default_translator_class,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'CheckExternalLinksBuilder' object has no attribute 'default_translator_class'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/PATH/TO/venv/lib/python3.11/site-packages/sphinx/cmd/build.py", line 496, in build_main
app = Sphinx(
^^^^^^^
File "/PATH/TO/venv/lib/python3.11/site-packages/sphinx/application.py", line 295, in __init__
self._init_builder()
File "/PATH/TO/venv/lib/python3.11/site-packages/sphinx/application.py", line 369, in _init_builder
self.events.emit('builder-inited')
File "/PATH/TO/venv/lib/python3.11/site-packages/sphinx/events.py", line 415, in emit
raise ExtensionError(
sphinx.errors.ExtensionError: Handler <function setup_translators at 0x7f73ec330400> for event 'builder-inited' threw an exception (exception: 'CheckExternalLinksBuilder' object has no attribute 'default_translator_class')
```
This PR adds a safe check for `app.builder.default_translator_class` and
skips the translator setup if the attribute is not defined.
I have tested the modified version with `linkcheck`, but I am not sure
where to add a unit test for these changes.
0 commit comments