Added try-catch for autodoc mock-import#89
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #89 +/- ##
==========================================
- Coverage 50.19% 50.15% -0.04%
==========================================
Files 18 18
Lines 1289 1292 +3
Branches 262 262
==========================================
+ Hits 647 648 +1
- Misses 598 600 +2
Partials 44 44
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| try: | ||
| from sphinx.ext.autodoc.mock import mock | ||
| except ImportError: | ||
| from sphinx.ext.autodoc import mock | ||
| # A persistent bug in sphinx / autodoc causes problems during importing (#82) | ||
|
|
There was a problem hiding this comment.
Hm, I'm a little in doubt now. I feel the intended method to import is the short version:
from sphinx.ext.autodoc import mock
So maybe we should prioritize that one. If for no other reason then to prevent us being the cause of an import error for the next package.
EDIT: I changed it but let's see what the bosses say over at sphinx-doc/sphinx#14333
|
FYI: We are still/again seeing this issue with khard 0.21.0, sphinx 9.1.0 when trying to build the package for Arch Linux: lucc/khard#356 |
88cd1f0 to
46a37d2
Compare
|
I want to merge this try-catch import, I think that should be future proof even if Sphinx rearranged their module structure. With pip you can do this with an install like this: |
|
I kind of want to get the release out. I can demonstrate locally that this works, so I'm merging it. |
Bumps [sphinx-argparse](https://github.com/sphinx-doc/sphinx-argparse) from 0.5.2 to 0.6.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/sphinx-doc/sphinx-argparse/releases">sphinx-argparse's releases</a>.</em></p> <blockquote> <h2>Release v0.6.0</h2> <h2>What's Changed</h2> <ul> <li>Added default feature to disable ArgumentParser coloring by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/74">sphinx-doc/sphinx-argparse#74</a></li> <li>Trying to fix RTD refusing to build by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/77">sphinx-doc/sphinx-argparse#77</a></li> <li>Moved color-disabling into <code>parse_parser</code> to fix subparsers by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/84">sphinx-doc/sphinx-argparse#84</a></li> <li>Unpinned ruff for CI + Cleaned up workflow files a little by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/79">sphinx-doc/sphinx-argparse#79</a></li> <li>Updated license metadata by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/81">sphinx-doc/sphinx-argparse#81</a></li> <li>Changed filename field to be explicit by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/88">sphinx-doc/sphinx-argparse#88</a></li> <li>Fixed MyPy by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/90">sphinx-doc/sphinx-argparse#90</a></li> <li>Added try-catch for autodoc mock-import by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/89">sphinx-doc/sphinx-argparse#89</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/sphinx-doc/sphinx-argparse/compare/v0.5.2...v0.6.0">https://github.com/sphinx-doc/sphinx-argparse/compare/v0.5.2...v0.6.0</a></p> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/sphinx-doc/sphinx-argparse/blob/main/docs/changelog.rst">sphinx-argparse's changelog</a>.</em></p> <blockquote> <p>0.6.0</p> <h5></h5> <p>The following enhancements to the HTML output are described on the :doc:<code>usage</code> page.</p> <ul> <li>Optional command index.</li> <li>Optional <code>:index-groups:</code> field to the directive for an command-by-group index.</li> <li>A <code>sphinxarg_full_subcommand_name</code> option to print fully-qualified sub-command headings. This option helps when more than one sub-command offers a <code>create</code> or <code>list</code> or other repeated sub-command.</li> <li>Each command heading is a domain-specific link target. You can link to commands and sub-commands with the <code>:ref:</code> role, but this release adds support for the domain-specific role like <code>:commands:command:`sample-directive-opts A` </code>. The <code>:commands:command:</code> role supports linking from other projects through the intersphinx extension.</li> </ul> <p>Changes</p> <ul> <li>Previously, common headings such as <strong>Positional Arguments</strong> were subject to a process that made them unique by adding a <code>_repeatX</code> suffix to the HREF target. This release continues to support those HREF targets as secondary targets so that bookmarks continue to work. However, this release prefers using fully-qualified HREF targets like <code>sample-directive-opts-positional-arguments</code> as the primary HREF so that customers are less likely to witness the <code>_repeatX</code> link in URLs.</li> <li><code>[#32](sphinx-doc/sphinx-argparse#32) <https://github.com/sphinx-doc/sphinx-argparse/issues/32></code>__ Argparse commands are now part of a Sphinx domain</li> <li><code>[#72](sphinx-doc/sphinx-argparse#72) <https://github.com/sphinx-doc/sphinx-argparse/issues/72></code>__ Coloring in argparse output can be disabled (default)</li> <li><code>[#87](sphinx-doc/sphinx-argparse#87) <https://github.com/sphinx-doc/sphinx-argparse/issues/87></code>__ The <code>:filename:</code> input is now resolved only to the <code>conf.py</code> directory (<code>srcdir</code> in Sphinx)</li> <li><code>[#89](sphinx-doc/sphinx-argparse#89) <https://github.com/sphinx-doc/sphinx-argparse/pull/89></code>__ Changed the way <code>mock</code> from <code>autodoc</code> is important to work around a persistent Sphinx bug</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/f918d4ebde3cef185ddd362de2967126716842be"><code>f918d4e</code></a> Bumped version to 0.6.0</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/9a74f452262db01bd969b7cb032cf1f91c07329b"><code>9a74f45</code></a> Updated changelog</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/8959ab6e9350fcdff51ec5e8656d6cbac7306ccc"><code>8959ab6</code></a> Dropped Sphinx upper version limit</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/034110391b1ff274bcad7042e3c8177b55684ab0"><code>0341103</code></a> Added try-catch for autodoc mock-import</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/528aa981c86f07990392d23edfb2564546093f20"><code>528aa98</code></a> Fixed mypy warning from CI</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/abd20c5b9ec1c6bb599354edcd2b6cf3839d248b"><code>abd20c5</code></a> Changed mypy python version to 3.13 + Fixed mypy in a test + Re-enabled mypy ...</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/61b8bf0e2ffab20664acaba99e0f16e6f04e0ad0"><code>61b8bf0</code></a> Updated changelog</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/de7c367545212653270c7195f6bea17e1406ce0e"><code>de7c367</code></a> Removed pass from OSerror</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/00964a323bd96922c91a703badf9e8476e7436f0"><code>00964a3</code></a> Updated docs</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/61365d08b88332860a2c92f0bd69b7be5856f6c8"><code>61365d0</code></a> Fixed tests through mock</li> <li>Additional commits viewable in <a href="https://github.com/sphinx-doc/sphinx-argparse/compare/v0.5.2...v0.6.0">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details>
Bumps [sphinx-argparse](https://github.com/sphinx-doc/sphinx-argparse) from 0.5.2 to 0.6.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/sphinx-doc/sphinx-argparse/releases">sphinx-argparse's releases</a>.</em></p> <blockquote> <h2>Release v0.6.0</h2> <h2>What's Changed</h2> <ul> <li>Added default feature to disable ArgumentParser coloring by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/74">sphinx-doc/sphinx-argparse#74</a></li> <li>Trying to fix RTD refusing to build by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/77">sphinx-doc/sphinx-argparse#77</a></li> <li>Moved color-disabling into <code>parse_parser</code> to fix subparsers by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/84">sphinx-doc/sphinx-argparse#84</a></li> <li>Unpinned ruff for CI + Cleaned up workflow files a little by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/79">sphinx-doc/sphinx-argparse#79</a></li> <li>Updated license metadata by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/81">sphinx-doc/sphinx-argparse#81</a></li> <li>Changed filename field to be explicit by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/88">sphinx-doc/sphinx-argparse#88</a></li> <li>Fixed MyPy by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/90">sphinx-doc/sphinx-argparse#90</a></li> <li>Added try-catch for autodoc mock-import by <a href="https://github.com/RobertoRoos"><code>@RobertoRoos</code></a> in <a href="https://redirect.github.com/sphinx-doc/sphinx-argparse/pull/89">sphinx-doc/sphinx-argparse#89</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/sphinx-doc/sphinx-argparse/compare/v0.5.2...v0.6.0">https://github.com/sphinx-doc/sphinx-argparse/compare/v0.5.2...v0.6.0</a></p> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/sphinx-doc/sphinx-argparse/blob/main/docs/changelog.rst">sphinx-argparse's changelog</a>.</em></p> <blockquote> <p>0.6.0</p> <h5></h5> <p>The following enhancements to the HTML output are described on the :doc:<code>usage</code> page.</p> <ul> <li>Optional command index.</li> <li>Optional <code>:index-groups:</code> field to the directive for an command-by-group index.</li> <li>A <code>sphinxarg_full_subcommand_name</code> option to print fully-qualified sub-command headings. This option helps when more than one sub-command offers a <code>create</code> or <code>list</code> or other repeated sub-command.</li> <li>Each command heading is a domain-specific link target. You can link to commands and sub-commands with the <code>:ref:</code> role, but this release adds support for the domain-specific role like <code>:commands:command:`sample-directive-opts A` </code>. The <code>:commands:command:</code> role supports linking from other projects through the intersphinx extension.</li> </ul> <p>Changes</p> <ul> <li>Previously, common headings such as <strong>Positional Arguments</strong> were subject to a process that made them unique by adding a <code>_repeatX</code> suffix to the HREF target. This release continues to support those HREF targets as secondary targets so that bookmarks continue to work. However, this release prefers using fully-qualified HREF targets like <code>sample-directive-opts-positional-arguments</code> as the primary HREF so that customers are less likely to witness the <code>_repeatX</code> link in URLs.</li> <li><code>[#32](sphinx-doc/sphinx-argparse#32) <https://github.com/sphinx-doc/sphinx-argparse/issues/32></code>__ Argparse commands are now part of a Sphinx domain</li> <li><code>[#72](sphinx-doc/sphinx-argparse#72) <https://github.com/sphinx-doc/sphinx-argparse/issues/72></code>__ Coloring in argparse output can be disabled (default)</li> <li><code>[#87](sphinx-doc/sphinx-argparse#87) <https://github.com/sphinx-doc/sphinx-argparse/issues/87></code>__ The <code>:filename:</code> input is now resolved only to the <code>conf.py</code> directory (<code>srcdir</code> in Sphinx)</li> <li><code>[#89](sphinx-doc/sphinx-argparse#89) <https://github.com/sphinx-doc/sphinx-argparse/pull/89></code>__ Changed the way <code>mock</code> from <code>autodoc</code> is important to work around a persistent Sphinx bug</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/f918d4ebde3cef185ddd362de2967126716842be"><code>f918d4e</code></a> Bumped version to 0.6.0</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/9a74f452262db01bd969b7cb032cf1f91c07329b"><code>9a74f45</code></a> Updated changelog</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/8959ab6e9350fcdff51ec5e8656d6cbac7306ccc"><code>8959ab6</code></a> Dropped Sphinx upper version limit</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/034110391b1ff274bcad7042e3c8177b55684ab0"><code>0341103</code></a> Added try-catch for autodoc mock-import</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/528aa981c86f07990392d23edfb2564546093f20"><code>528aa98</code></a> Fixed mypy warning from CI</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/abd20c5b9ec1c6bb599354edcd2b6cf3839d248b"><code>abd20c5</code></a> Changed mypy python version to 3.13 + Fixed mypy in a test + Re-enabled mypy ...</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/61b8bf0e2ffab20664acaba99e0f16e6f04e0ad0"><code>61b8bf0</code></a> Updated changelog</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/de7c367545212653270c7195f6bea17e1406ce0e"><code>de7c367</code></a> Removed pass from OSerror</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/00964a323bd96922c91a703badf9e8476e7436f0"><code>00964a3</code></a> Updated docs</li> <li><a href="https://github.com/sphinx-doc/sphinx-argparse/commit/61365d08b88332860a2c92f0bd69b7be5856f6c8"><code>61365d0</code></a> Fixed tests through mock</li> <li>Additional commits viewable in <a href="https://github.com/sphinx-doc/sphinx-argparse/compare/v0.5.2...v0.6.0">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details>
Resolving #82 (again...)
This is the suggestion of @lucc , posted here: #82 (comment)