-
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
Bug with return annotation when using @contextmanager
#68
Comments
Changing |
...using iterator should work though 😉 |
Hi @haakonvt , You touched on a point that many other people may agree with (or may be confused about). I sort of have the opinion that when we use That's why when pydoclint sees You may be wondering: when would an from typing import Any, Iterator, Tuple, List
def zip_lists(list1: List[Any], list2: List[Any]) -> Iterator[Tuple[Any, Any]]:
return zip(list1, list2) |
Thanks for the detailed answer. I think your logic is sound (and I don't mind annotating as Generator), but you can also turn it around: All functions returning an Iterator with a yield statement present are generators (afaik). |
Yes, this is correct. But this would introduce an ambiguity: when pydoclint sees You might wonder: can we check the existence of Therefore, the only unambiguous way becomes the following:
There is some adoption cost to this: users (such as you) would need to update a lot of the return annotations from |
That said, the fact that you saw this violation ("DOC203: Function I'll work on a code change to improve the explanation. |
I made a code change (#70) to explicitly show this self explanatory violation:
|
That is a greatly improved error message 👌 |
This change is included in the new published version, 0.2.0. |
I use
contextmanager
in several places in my testing utilities, and one of these functions are part of the public API, meaning it's documented. I struggle to write it in a manner that does not raise any errors frompydoclint
:Running this file gives me a
DOC203
error:I have tried several variations, but all lead to at least one error 🤔 Any suggestions?
The text was updated successfully, but these errors were encountered: