summaryrefslogtreecommitdiff
path: root/logilab/common/decorators.py
diff options
context:
space:
mode:
Diffstat (limited to 'logilab/common/decorators.py')
-rw-r--r--logilab/common/decorators.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/logilab/common/decorators.py b/logilab/common/decorators.py
index b7228e9..3367e16 100644
--- a/logilab/common/decorators.py
+++ b/logilab/common/decorators.py
@@ -21,6 +21,9 @@ from __future__ import print_function
__docformat__ = "restructuredtext en"
+import os
+import sys
+
from time import process_time, time
from inspect import isgeneratorfunction
from typing import Any, Optional, Callable, Union
@@ -155,12 +158,14 @@ class cachedproperty(object):
raise TypeError("%s must have a __name__ attribute" % wrapped)
self.wrapped = wrapped
- # mypy: Signature of "__doc__" incompatible with supertype "object"
- # but this works?
- @property
- def __doc__(self) -> str: # type: ignore
- doc = getattr(self.wrapped, "__doc__", None)
- return "<wrapped by the cachedproperty decorator>%s" % ("\n%s" % doc if doc else "")
+ # otherwise this breaks sphinx static analysis for __doc__
+ if os.path.basename(sys.argv[0]) != "sphinx-build":
+ # mypy: Signature of "__doc__" incompatible with supertype "object"
+ # but this works?
+ @property
+ def __doc__(self) -> str: # type: ignore
+ doc = getattr(self.wrapped, "__doc__", None)
+ return "<wrapped by the cachedproperty decorator>%s" % ("\n%s" % doc if doc else "")
def __get__(self, inst, objtype=None):
if inst is None: