FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-101100: Fix Sphinx warnings in `library/unittest.mock.rst` by hugovk · Pull Request #124106 · python/cpython · GitHub

Repository navigation

gh-101100: Fix Sphinx warnings in library/unittest.mock.rst - #124106

Merged
hugovk merged 2 commits into
python:mainfrom
hugovk:docs-fix-sphinx-warnings-unittest.mock
Oct 9, 2024
Merged

hugovk merged 2 commits into
python:mainfrom
hugovk:docs-fix-sphinx-warnings-unittest.mock

Conversation

hugovk commented Sep 15, 2024 •
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member

Fix 26 warnings in library/unittest.mock.rst:

Before:

❯ make -C Doc html SPHINXOPTS="-n -W --keep-going" SOURCES="library/unittest.mock.rst" 2>&1 | grep WARNING | tee >(wc -l)
library/unittest.mock.rst:71: WARNING: py:attr reference target not found: side_effect [ref.attr]
library/unittest.mock.rst:740: WARNING: py:attr reference target not found: spec [ref.attr]
library/unittest.mock.rst:763: WARNING: py:attr reference target not found: spec [ref.attr]
library/unittest.mock.rst:763: WARNING: py:attr reference target not found: spec_set [ref.attr]
library/unittest.mock.rst:1177: WARNING: py:attr reference target not found: side_effect [ref.attr]
library/unittest.mock.rst:1199: WARNING: py:attr reference target not found: side_effect [ref.attr]
library/unittest.mock.rst:1199: WARNING: py:attr reference target not found: side_effect [ref.attr]
library/unittest.mock.rst:1215: WARNING: py:attr reference target not found: mock.return_value [ref.attr]
library/unittest.mock.rst:1215: WARNING: py:attr reference target not found: side_effect [ref.attr]
library/unittest.mock.rst:1234: WARNING: py:attr reference target not found: side_effect [ref.attr]
library/unittest.mock.rst:1234: WARNING: py:attr reference target not found: side_effect [ref.attr]
library/unittest.mock.rst:1248: WARNING: py:attr reference target not found: side_effect [ref.attr]
library/unittest.mock.rst:1287: WARNING: py:attr reference target not found: spec [ref.attr]
library/unittest.mock.rst:1458: WARNING: py:class reference target not found: TestCase [ref.class]
library/unittest.mock.rst:1495: WARNING: py:attr reference target not found: return_value [ref.attr]
library/unittest.mock.rst:1818: WARNING: py:meth reference target not found: start [ref.meth]
library/unittest.mock.rst:1818: WARNING: py:meth reference target not found: stop [ref.meth]
library/unittest.mock.rst:1822: WARNING: py:meth reference target not found: start [ref.meth]
library/unittest.mock.rst:1822: WARNING: py:meth reference target not found: stop [ref.meth]
library/unittest.mock.rst:1840: WARNING: py:class reference target not found: TestCase [ref.class]
library/unittest.mock.rst:2204: WARNING: py:meth reference target not found: MagicMock.__iter__ [ref.meth]
library/unittest.mock.rst:2512: WARNING: py:const reference target not found: mock.FILTER_DIR [ref.const]
library/unittest.mock.rst:2529: WARNING: py:meth reference target not found: io.IOBase.read [ref.meth]
library/unittest.mock.rst:2540: WARNING: py:meth reference target not found: io.IOBase.read [ref.meth]
library/unittest.mock.rst:2593: WARNING: py:attr reference target not found: spec [ref.attr]
library/unittest.mock.rst:2618: WARNING: py:mod reference target not found: mock [ref.mod]
library/unittest.mock.rst:2618: WARNING: py:attr reference target not found: spec [ref.attr]
library/unittest.mock.rst:2657: WARNING: py:class reference target not found: request.Request [ref.class]
library/unittest.mock.rst:2657: WARNING: py:class reference target not found: request.Request [ref.class]
library/unittest.mock.rst:2673: WARNING: py:class reference target not found: Request [ref.class]
library/unittest.mock.rst:2673: WARNING: py:class reference target not found: request.Request [ref.class]
library/unittest.mock.rst:2826: WARNING: py:attr reference target not found: side_effect [ref.attr]
library/unittest.mock.rst:2826: WARNING: py:attr reference target not found: return_value [ref.attr]
      33

After:

❯ make -C Doc html SPHINXOPTS="-n -W --keep-going" SOURCES="library/unittest.mock.rst" 2>&1 | grep WARNING | tee >(wc -l)
library/unittest.mock.rst:740: WARNING: py:attr reference target not found: spec [ref.attr]
library/unittest.mock.rst:763: WARNING: py:attr reference target not found: spec [ref.attr]
library/unittest.mock.rst:763: WARNING: py:attr reference target not found: spec_set [ref.attr]
library/unittest.mock.rst:1287: WARNING: py:attr reference target not found: spec [ref.attr]
library/unittest.mock.rst:2204: WARNING: py:meth reference target not found: MagicMock.__iter__ [ref.meth]
library/unittest.mock.rst:2593: WARNING: py:attr reference target not found: spec [ref.attr]
library/unittest.mock.rst:2618: WARNING: py:attr reference target not found: spec [ref.attr]
       7

📚 Documentation preview 📚: https://cpython-previews--124106.org.readthedocs.build/

Comment thread Doc/library/unittest.mock.rst Outdated
Normally the :attr:`__class__` attribute of an object will return its type.
For a mock object with a :attr:`spec`, ``__class__`` returns the spec class
Normally the :attr:`!__class__` attribute of an object will return its type.
For a mock object with a :attr:`spec`, :attr:`!__class__` returns the spec class

picnixz Sep 16, 2024 •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The spec attribute seems to be missing or is it an inherited one? (Maybe we could fix it in this PR directly?). Or is it a Sphinx issue?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think it (and spec_set) are just missing documentation under https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock

For example, here's side_effect:

https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.side_effect

Would you like to suggest some text?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I never used it so I cannot really suggest a good text. I'll leave that task to unittest experts! but we can do it in another PR otherwise.

hugovk added needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes labels Sep 16, 2024
Comment thread Doc/library/unittest.mock.rst Outdated

:mod:`mock` already provides a feature to help with this, called speccing. If you
:mod:`unittest.mock` already provides a feature to help with this, called speccing. If you
use a class or instance as the :attr:`spec` for a mock then you can only access

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

There is a warning on "spec" here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yep, it's not yet documented, can you suggest some text for it? Also for spec_set?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Maybe just write :attr:`!spec` .

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done, and also for spec_set.

hugovk merged commit a5716a3 into python:main Oct 9, 2024
hugovk deleted the docs-fix-sphinx-warnings-unittest.mock branch October 9, 2024 14:02

Copy link
Copy Markdown

Thanks @hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 9, 2024
…ythonGH-124106)

(cherry picked from commit a5716a3)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 9, 2024
…ythonGH-124106)

(cherry picked from commit a5716a3)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>

bedevere-app Bot commented Oct 9, 2024

Copy link
Copy Markdown

GH-125190 is a backport of this pull request to the 3.13 branch.

bedevere-app Bot removed the needs backport to 3.13 only security fixes label Oct 9, 2024

bedevere-app Bot commented Oct 9, 2024

Copy link
Copy Markdown

GH-125191 is a backport of this pull request to the 3.12 branch.

bedevere-app Bot removed the needs backport to 3.12 only security fixes label Oct 9, 2024
hugovk added a commit that referenced this pull request Oct 9, 2024
…H-124106) (#125190)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
hugovk added a commit that referenced this pull request Oct 9, 2024
…H-124106) (#125191)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL