mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #9079 from tk0miya/9078_async_staticmethod
Fix autodoc: Async staticmethods/ classmethods are considered as not async
This commit is contained in:
commit
43dc09175f
2
CHANGES
2
CHANGES
@ -18,6 +18,8 @@ Features added
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
* #9078: autodoc: Async staticmethods and classmethods are considered as non
|
||||
async coroutine-functions with Python3.10
|
||||
* #8870: The style of toctree captions has been changed with docutils-0.17
|
||||
* #9001: The style of ``sidebar`` directive has been changed with docutils-0.17
|
||||
|
||||
|
@ -352,8 +352,18 @@ def isroutine(obj: Any) -> bool:
|
||||
|
||||
def iscoroutinefunction(obj: Any) -> bool:
|
||||
"""Check if the object is coroutine-function."""
|
||||
# unwrap staticmethod, classmethod and partial (except wrappers)
|
||||
obj = unwrap_all(obj, stop=lambda o: hasattr(o, '__wrapped__'))
|
||||
def iswrappedcoroutine(obj: Any) -> bool:
|
||||
"""Check if the object is wrapped coroutine-function."""
|
||||
if isstaticmethod(obj) or isclassmethod(obj) or ispartial(obj):
|
||||
# staticmethod, classmethod and partial method are not a wrapped coroutine-function
|
||||
# Note: Since 3.10, staticmethod and classmethod becomes a kind of wrappers
|
||||
return False
|
||||
elif hasattr(obj, '__wrapped__'):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
obj = unwrap_all(obj, stop=iswrappedcoroutine)
|
||||
if hasattr(obj, '__code__') and inspect.iscoroutinefunction(obj):
|
||||
# check obj.__code__ because iscoroutinefunction() crashes for custom method-like
|
||||
# objects (see https://github.com/sphinx-doc/sphinx/issues/6605)
|
||||
|
Loading…
Reference in New Issue
Block a user