-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Avoiding rtype checks with typed code: No return type or annotation at ':return: ... #125
Comments
Hello, thanks for the report! I'm a bit confused: this warning is supposed to be emitted only when there is no annotation in the signature and no annotation in the docstring. But I didn't write the Could you show a code snippet that triggers the undesired warning? |
Here is an example that also includes the workaround for it https://github.com/ansible-community/molecule/pull/3811/files#diff-32abfdacc4eeea878460d3bf0ae452ab074ca485bab0b0a01b3bb07775ac002dR399-R630 Basically I removed the |
The example you linked actually confirms what I said above: https://github.com/ansible-community/molecule/pull/3811/files#diff-32abfdacc4eeea878460d3bf0ae452ab074ca485bab0b0a01b3bb07775ac002dR606-R628 You removed the Or did I misunderstood the Sphinx directives? |
Closing for now, feel free to reopen if needed. |
This seems to happen with properties ( @property
def example(self) -> bool:
"""
Property that returns True for explaining the issue.
:return: True
"""
return True
@property
def example2(self) -> bool:
"""
Property that returns True for explaining the issue.
:return bool: True
"""
return True
@property
def example3(self) -> bool:
"""
Property that returns True for explaining the issue.
:return: True
:rtype: bool
"""
return True
def example4(self) -> bool:
"""
Property that returns True for explaining the issue.
:return: True
"""
return True Gives:
Note the normal method does not trigger a warning, even without a Sphinx style type annotation. |
Describe the bug
Once a library adopts type support is it very unlikely that the maintainers will want to duplicate the type information inside the docstrings. That duplication is a real maintenance issue and also a permanent source of bugs, as it is very easy to miss updating the docstring when changing the type.
I personally faced
griffe/src/griffe/docstrings/sphinx.py
Line 298 in 34bc108
That typing issue is so important that we are willing to switch to a different docstring format.
Currently we use sphinx for historical reasons and anything going towards markdown and less verbosity/duplication would be appealing.
The text was updated successfully, but these errors were encountered: