diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-11-11 18:44:03 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-11-21 12:25:46 +0300 |
commit | e5424b38e981b7b61184583a7ebc8c124d1e9a1e (patch) | |
tree | 8e735270cfa32f95065278f9e44a339ab43220bc /sphinx/util | |
parent | 8e0c7a75f8d818171144e7fd5b6e1f9202272ac3 (diff) |
Fix #9838: autodoc: AttributeError is raised for lru_cache
Diffstat (limited to 'sphinx/util')
-rw-r--r-- | sphinx/util/inspect.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index 7e45fe322..3a39bde1d 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -19,8 +19,7 @@ import typing import warnings from functools import partial, partialmethod from importlib import import_module -from inspect import (Parameter, isasyncgenfunction, isclass, ismethod, # NOQA - ismethoddescriptor, ismodule) +from inspect import Parameter, isclass, ismethod, ismethoddescriptor, ismodule # NOQA from io import StringIO from types import ModuleType from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, Type, cast @@ -408,6 +407,16 @@ def iscoroutinefunction(obj: Any) -> bool: 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: """Check if the object is property.""" if sys.version_info >= (3, 8): |