-
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
Yields section requires wrong type annotation #75
Comments
All of these docstring/type-annotation combinations for this function are valid and should be allowed:
|
Hi @erlendvollset , thank you for providing those examples! My fix addresses the 1st combination: def foo(n: int) -> Generator[int, None, None]:
"""Description
Args:
n (int): Description
Yields:
int: Description
"""
yield from range(n) The 2nd combination you mentioned above is a very interesting idea. I'll need to think about how to implement it though. (And if it "interferes" with existing violation checking logic, I may choose not to implement it.) As to the 3rd and the 4th combinations, please read this note that I wrote: https://jsh9.github.io/pydoclint/notes_generator_vs_iterator.html |
@jsh9 Just updated, worked for all cases except one which reports a
The code that triggered it: from typing import Generator
class Foo:
def create(self, n: int) -> Generator[tuple[float, ...], None, None]:
"""Foo
Args:
n (int): Description.
Yields:
tuple[float, ...]: Description.
"""
yield from ((*self.bar, i) for i in range(self.baz)) |
Yep, I just realized that issue too. I fixed it in v0.2.4. |
Hi @erlendvollset and @haakonvt : I released v0.3.0, which allowed this combination in your example: def foo3(n: int) -> Iterator[int]:
"""Description
Args:
n (int): Description
Yields:
int: Description
"""
yield from range(n) See this issue (#76) for more details. |
For a generator (function) like the following, according to the Google style docs, the annotation in the
Yields:
section should be annotated as follows:This throws an error when I try to run it through
pydoclint
:I.e., it wants:
Is this a bug?
The text was updated successfully, but these errors were encountered: