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

Suppress mock object warnings from autodoc #9655

Closed
sdhiscocks opened this issue Sep 20, 2021 · 3 comments
Closed

Suppress mock object warnings from autodoc #9655

sdhiscocks opened this issue Sep 20, 2021 · 3 comments

Comments

@sdhiscocks
Copy link
Contributor

Is your feature request related to a problem? Please describe.
When building with warnings as errors (-W flag), mock objects cause build failure (for example below).

WARNING: A mocked object is detected: 'example.mock.object'

This occurs with class attributes, or enum members, pointing to mock objects, even if they are documented with #:, which produce valid documentation.

Describe the solution you'd like
As suggested in #9631, it would be useful to have a subtype on the warning (e.g. mock_objects) so these warnings can be ignored.

Describe alternatives you've considered
Suppressing all autodoc warnings works, but this isn't ideal.

Additional context

@tk0miya
Copy link
Member

tk0miya commented Sep 20, 2021

I think the warnings should not be emitted if the mocked object can produce valid docs. I think it's a bug of autodoc that emits incorrect warnings. So I don't think it's better to suppress them.

Could you share an example to reproduce the warning? I'll try to fix it.

@tk0miya tk0miya added type:bug and removed type:enhancement enhance or introduce a new feature labels Sep 20, 2021
@sdhiscocks
Copy link
Contributor Author

So issue we've seen is with this Enum we have defined, where the enum name points to a (mocked) function. The Enum documentation looks fine despite the warning.

We have a recent build on CircleCI which got caught on this warning, but no issues with documentation it produced.

@tk0miya
Copy link
Member

tk0miya commented Sep 23, 2021

Thank you for example. I understand what happened. The enum subclass provides _generate_next_value_() method that generates value from tensornets module (it's mocked!) for enum.auto(). I also reproduced.

Note: Dockefile to reproduce the error:

FROM python:3.8-slim

RUN apt update; apt install -y build-essential curl git unzip vim
RUN git clone https://github.com/dstl/Stone-Soup
WORKDIR Stone-Soup
RUN pip install -e .[dev]
WORKDIR /Stone-Soup/docs
RUN make HTML

tk0miya added a commit to tk0miya/sphinx that referenced this issue Sep 23, 2021
…ned unexpectedly

A warning for mocked object should not be emitted if it has doc comment.
tk0miya added a commit to tk0miya/sphinx that referenced this issue Sep 23, 2021
…ned unexpectedly

A warning for mocked object should not be emitted if it has doc comment.
tk0miya added a commit that referenced this issue Sep 25, 2021
…mment

Fix #9655: autodoc: mocked object having doc comment is warned unexpectedly
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants