summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2022-02-15 10:51:52 +0000
committerCalum Lind <calumlind+deluge@gmail.com>2022-02-15 11:49:54 +0000
commit62a40521789eab273415550ea741ed668b2e947e (patch)
tree518d95984354f19ac58b1fa0971af30df0257161
parent8ece036770484e170d5a728cdb25062088068f71 (diff)
downloaddeluge-62a40521789eab273415550ea741ed668b2e947e.tar.gz
deluge-62a40521789eab273415550ea741ed668b2e947e.tar.bz2
deluge-62a40521789eab273415550ea741ed668b2e947e.zip
[Docs] Remove custom mock to fix autodoc typing errors
If a libtorrent return type was specified e.g. def get_lt_status(self) -> 'lt.torrent_status' Even as a string autodoc_typehints module would raise and error: Handler <function process_docstring at 0x7f6c16c8ec10> for event 'autodoc-process-docstring' threw an exception (exception: getattr(): attribute name must be string) This was a result of using a custom mock in Sphinx autodoc config and this Mock object name or qualname returns an object instead of str. Testing with putting modules in autodoc_mock_imports again showed no issues so removing custom mock Ref: https://github.com/tox-dev/sphinx-autodoc-typehints/issues/220
-rw-r--r--docs/source/conf.py34
1 files changed, 1 insertions, 33 deletions
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 9c5853c73..0e4a41914 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -219,45 +219,13 @@ latex_documents = [
# Autodoc section
# ---------------
-class Mock:
-
- __all__ = []
-
- def __init__(self, *args, **kwargs):
- pass
-
- def __call__(self, *args, **kwargs):
- return ''
-
- @classmethod
- def __getattr__(cls, name):
- if name in ('__file__', '__path__', 'xdg_config_home'):
- return '/dev/null'
- elif name[0] == name[0].upper():
- mock_type = type(name, (), {})
- mock_type.__module__ = __name__
- return mock_type
- else:
- return Mock()
-
- def __add__(self, other):
- return other
-
- def __or__(self, __):
- return Mock()
-
-
-# Use custom mock as autodoc_mock_imports fails to handle these modules.
-MOCK_MODULES = ['deluge._libtorrent', 'xdg', 'xdg.BaseDirectory']
-
-for mod_name in MOCK_MODULES:
- sys.modules[mod_name] = Mock()
# Must add these for autodoc to import packages successfully
builtins.__dict__['_'] = lambda x: x
builtins.__dict__['_n'] = lambda s, p, n: s if n == 1 else p
autodoc_mock_imports = [
+ 'deluge._libtorrent',
'twisted',
'rencode',
'OpenSSL',