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

Remove redundant return type for attributes #287

Merged
merged 7 commits into from
Jan 15, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/sphinx_autodoc_typehints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,11 @@ def _inject_types_to_docstring(

lines.insert(insert_index, type_annotation)

if "return" in type_hints and not inspect.isclass(original_obj):
if (
"return" in type_hints
and not inspect.isclass(original_obj)
and not inspect.isdatadescriptor(original_obj) # noqa: SC200 # Possibly misspelt word: 'isdatadescriptor'
Copy link
Member

Choose a reason for hiding this comment

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

Add this word to whitelist.txt instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay. We also need to add getitem there...

):
if what == "method" and name.endswith(".__init__"): # avoid adding a return type for data class __init__
return
formatted_annotation = format_annotation(type_hints["return"], app.config)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_sphinx_autodoc_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,6 @@ class InnerClass

Property docstring

Return type:
"str"

static a_staticmethod(x, y, z=None)

Staticmethod docstring.
Expand Down