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

DOC Fix sphinx warnings and turn warnings into errors #1247

Merged
merged 6 commits into from
Feb 11, 2021

Conversation

NicolasHug
Copy link
Member

Similar to what was done in torchvision pytorch/vision#3290

This PR fixes sphinx warnings and sets the

napoleon_numpy_docstring = False
napoleon_google_docstring = True

for sphinx to issue warnings when the wrong parameter syntax is used.

The warnings are now turned into errors. Note: sphinx will now stop compilation at the first warning/error it sees; if we relied on sphinx>=8, we could use the --keep-going option to let it finish.

Comment on lines 47 to 49
# get __init__ if obj is a class, else get the function itself
# FIXME: remove when SignalInfo and EncodingInfo are properly removed
func = getattr(obj, '__init__', obj)
Copy link
Member Author

Choose a reason for hiding this comment

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

For ref, this is needed to avoid a similar error as in astropy/astropy#2051.

The main issue is that decorator doesn't work on classes; it only works on functions but it's currently used for the SignalInfo and EncodingInfo classes which led to the warning / error.

I'm not sure the current changes properly makes the decorator work on classes - but it does successfully suppress the warning, and as the offending classes are deprecated and will be removed, I assumed it was good enough.

If needed, I'm happy to propose a proper fix and let the decorator work on classes, but that will be a bit more work

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the clarification. SignalInfo and EncodingInfo classes are expected to be removed after the next release (if things go smoothly) so I think this workaround is good enough.

Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't make it work properly after all, so I removed the changes to the decorator and removed its us in the corresponding classes, and instead warned inside __init__

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good.

@mthrok
Copy link
Collaborator

mthrok commented Feb 8, 2021

Looks like deprecated decorator is affected. What do you think is the best (easiest) way to resolve this?
Do you see an issue in the way deprecated decorator is written?

@NicolasHug NicolasHug changed the title Fix sphinx warnings and turn warnings into errors DOC Fix sphinx warnings and turn warnings into errors Feb 11, 2021
@NicolasHug NicolasHug merged commit a7e93c1 into pytorch:master Feb 11, 2021
@NicolasHug NicolasHug deleted the docs_google_style_and_warnigns branch February 11, 2021 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants