Skip to content
2 changes: 1 addition & 1 deletion src/sphinx_autodoc_typehints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ 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):
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
7 changes: 2 additions & 5 deletions tests/test_sphinx_autodoc_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def method(self: T) -> T:
# We could also set AbcCallable = typing.Callable and x fail the tests that
# use AbcCallable when in versions less than 3.9.
class MyGenericAlias(typing._VariadicGenericAlias, _root=True): # noqa: SC200
def __getitem__(self, params): # noqa: SC200
result = super().__getitem__(params) # noqa: SC200
def __getitem__(self, params):
result = super().__getitem__(params)
# Make a copy so we don't change the name of a cached annotation
result = result.copy_with(result.__args__)
result.__module__ = "collections.abc"
Expand Down Expand Up @@ -574,9 +574,6 @@ class InnerClass

Property docstring

Return type:
"str"

static a_staticmethod(x, y, z=None)

Staticmethod docstring.
Expand Down
2 changes: 2 additions & 0 deletions whitelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ fmt
fn
formatter
func
getitem
getmodule
getsource
globals
idx
inited
inv
isdatadescriptor
isfunction
iterdir
kwonlyargs
Expand Down