mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #9838: autodoc: AttributeError is raised for lru_cache
This commit is contained in:
parent
8e0c7a75f8
commit
ea38d96298
3
CHANGES
3
CHANGES
@ -16,6 +16,9 @@ Features added
|
|||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
* #9838: autodoc: AttributeError is raised on building document for functions
|
||||||
|
decorated by functools.lru_cache
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@ -19,8 +19,7 @@ import typing
|
|||||||
import warnings
|
import warnings
|
||||||
from functools import partial, partialmethod
|
from functools import partial, partialmethod
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from inspect import (Parameter, isasyncgenfunction, isclass, ismethod, # NOQA
|
from inspect import Parameter, isclass, ismethod, ismethoddescriptor, ismodule # NOQA
|
||||||
ismethoddescriptor, ismodule)
|
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, Type, cast
|
from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, Type, cast
|
||||||
@ -408,6 +407,16 @@ def iscoroutinefunction(obj: Any) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def isasyncgenfunction(obj: Any) -> bool:
|
||||||
|
"""Check if the object is async-gen function."""
|
||||||
|
if hasattr(obj, '__code__') and inspect.isasyncgenfunction(obj):
|
||||||
|
# check obj.__code__ because isasyncgenfunction() crashes for custom method-like
|
||||||
|
# objects on python3.7 (see https://github.com/sphinx-doc/sphinx/issues/9838)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def isproperty(obj: Any) -> bool:
|
def isproperty(obj: Any) -> bool:
|
||||||
"""Check if the object is property."""
|
"""Check if the object is property."""
|
||||||
if sys.version_info >= (3, 8):
|
if sys.version_info >= (3, 8):
|
||||||
|
Loading…
Reference in New Issue
Block a user