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

Add missing-raises-doc rule to the linter and subsequent refactor. #4345

Merged
merged 3 commits into from
Aug 16, 2021

Conversation

thanacles
Copy link

This is associated to issue #3388

Copy link
Contributor

@balopat balopat left a comment

Choose a reason for hiding this comment

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

LGTM

@CirqBot CirqBot added size: XL lines changed >1000 size: L 250< lines changed <1000 and removed size: XL lines changed >1000 labels Aug 12, 2021
@thanacles thanacles force-pushed the docparams branch 2 times, most recently from 9f65e5e to bb4f088 Compare August 15, 2021 20:09
@thanacles
Copy link
Author

thanacles commented Aug 15, 2021

@balopat Fixed the merge conflicts and a few places where problem pydocs where added since this PR was formed. I feel like we only have a small window before this PR will have further merge conflicts and lint violations.

@balopat
Copy link
Contributor

balopat commented Aug 16, 2021

Agreed, let's do it!

@balopat balopat added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Aug 16, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Aug 16, 2021
@CirqBot CirqBot merged commit 6e5d684 into quantumlib:master Aug 16, 2021
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Aug 16, 2021
@thanacles thanacles deleted the docparams branch August 16, 2021 21:01
@mpharrigan
Copy link
Collaborator

I think this change adds more developer overhead than value it provides. I've rarely seen exceptions documented this way in Python. It's usually very clear what has happened when an exception is raised because of the message. If it's not, we should fix the message and not the docstring.

@thanacles
Copy link
Author

@mpharrigan I agree it adds more developer overhead, and it would be hard for me to show how much value it provides. However, I don't think this is for helping people who are getting the error. This is for people to know what can happen when calling the function, so that they can prevent ever getting the error in the first place. That said, I recognize it is a judgement call whether it should be implemented. This commit was called for by bug #3388 , so that bug should be changed if you don't want more commits like this.

@mpharrigan
Copy link
Collaborator

Summarizing some offline discussion; my apologies in advance if I've mischaracterized anyone's opinion:

We should only be documenting the public API. If we document ValueErrors that arise from bad inputs, we're irionically making those bad inputs part of the public API. See https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings "raises" section.

You should not document exceptions that get raised if the API specified in the docstring is violated (because this would paradoxically make behavior under violation of the API part of the API).


@Strilanc wants to clarify that he's ok with exceptions being documented in the Raises section but he doesn't think it should be mandated.

I personally think we should document exceptions in only rare cases.

@MichaelBroughton thinks we should include this check because a similar check is present for internal-google code

@maffoo made analogy to Java's "checked" vs "unchecked" exceptions. You'd want to document the former but not the latter. Python doesn't have this distinction and the tool isn't sophisticated enough to distinguish

@thanacles
Copy link
Author

thanacles commented Aug 26, 2021

I agree with @maffoo and @MichaelBroughton. I'm willing to remove the check and disable/enable comments if consensus is reached that we shouldn't have it. Also, there are a lot of similar checks that haven't been implemented yet, I think now would be the perfect time to discuss those rules. See: #3388 (comment)

rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining. size: L 250< lines changed <1000
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants