-
Notifications
You must be signed in to change notification settings - Fork 16
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
[DOC403/DOC502] False positive for abstract methods #31
Comments
Pydoclint wants you to document that the method returns an Iterator which is different from yielding values which makes the method return a Generator. This is linked to #15. |
Thanks! So I guess that's one more edge-case for DOC201 😉 The rule would be something like if a method is abstract and its output is either Iterable/Iterator/Generator and it contains a yield section, then DOC201 doesn't apply? |
But why would you want to have a yield section but not a Generator return type? |
For exactly the same reason as mentioned there: #15 (comment) |
Hi @ghjklw: Thank you for raising this issue. This is indeed an edge case that I didn't think of. Let me explain the "strange" behavior between your Example 1 and Example 2. In Example 1, pydoclint raises DOC201 and DOC403 because: it sees a This is because: when we see The situation is different for Example 2, where there is That's why I wrote pydoclint/pydoclint/visitor.py Lines 449 to 450 in 31e6a0b
So I actually don't know what the best solution should be: are we OK that both |
Hi @ghjklw : I merged PR #35. Please feel free to take a look at the code change, if you are curious. Please note that your 1st example will still trigger violations, because if the return type annotation is If you have better suggestions on how the linter should handle Iterator/Generator and yields, please feel free to share them! |
Thanks! I think that's a good compromise. Thinking again about this example I think @real-yfprojects has a point regarding the use of
By the way, thanks for all the work you're doing ! It's fantastic to have such a tool 😃 I only hope I had the skills to build a VS Code extension for it 😄 ! |
That's exactly what I was thinking. |
Thank you both for sharing useful feedback! With the discussions above, I'm going to close this issue as "fixed". Please feel free to reopen it if any additional fixing is necessary. |
Abstract method / abstract classes should be able to define a signature/docstring containing Yields or Raises sections even though they do not contain a yield or raise statement.
For example:
Results in:
I also do not understand with DOC201 is triggered in this case.
NB: DOC202 is not impacted, the following code does not trigger any warning:
The text was updated successfully, but these errors were encountered: