Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #8103: autodoc: cached_property is not considered as a property
sphinx.util.inspect:isproperty() does not considers that cached_property decorator that has been added since Python 3.8 is a kind of properties. This fixes it.
- Loading branch information
Showing
4 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -304,6 +304,11 @@ def iscoroutinefunction(obj: Any) -> bool: | |
|
||
def isproperty(obj: Any) -> bool: | ||
"""Check if the object is property.""" | ||
if sys.version_info > (3, 8): | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tk0miya
Author
Member
|
||
from functools import cached_property # cached_property is available since py3.8 | ||
if isinstance(obj, cached_property): | ||
return True | ||
|
||
return isinstance(obj, property) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from functools import cached_property | ||
|
||
|
||
class Foo: | ||
@cached_property | ||
def prop(self) -> int: | ||
return 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shouldn't this be
if sys.version_info >= (3, 8)
ifcached_property
was added in 3.8?