From 3cb077d499ab40f4656d8a44a90df8d2ed1ac00c Mon Sep 17 00:00:00 2001
From: Peter Cock
Date: Fri, 3 Jul 2020 21:10:13 +0100
Subject: [PATCH 1/2] Cope with unexpected signature
Fixes a regression in numpydoc v1.1.0 compared to v1.0.0 which did not have the _clean_text_signature function.
---
numpydoc/numpydoc.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/numpydoc/numpydoc.py b/numpydoc/numpydoc.py
index 93cd975d..438fc8cc 100644
--- a/numpydoc/numpydoc.py
+++ b/numpydoc/numpydoc.py
@@ -215,7 +215,10 @@ def _clean_text_signature(sig):
if sig is None:
return None
start_pattern = re.compile(r"^[^(]*\(")
- start, end = start_pattern.search(sig).span()
+ try:
+ start, end = start_pattern.search(sig).span()
+ except TypeError:
+ return None
start_sig = sig[start:end]
sig = sig[end:-1]
sig = re.sub(r'^\$(self|module|type)(,\s|$)','' , sig, count=1)
From 0acfb441ac4c10aa14dfb8e4e6a5d44c679d2664 Mon Sep 17 00:00:00 2001
From: Peter Cock
Date: Fri, 3 Jul 2020 21:26:12 +0100
Subject: [PATCH 2/2] Confirm no TypeError from _clean_text_signature
User defined classes can do strange things.
---
numpydoc/tests/test_numpydoc.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/numpydoc/tests/test_numpydoc.py b/numpydoc/tests/test_numpydoc.py
index 77e75400..c20b71d6 100644
--- a/numpydoc/tests/test_numpydoc.py
+++ b/numpydoc/tests/test_numpydoc.py
@@ -66,6 +66,7 @@ def test_mangle_docstrings():
def test_clean_text_signature():
assert _clean_text_signature(None) is None
+ assert _clean_text_signature({"a": 1}) is None # i.e. not a string
assert _clean_text_signature('func($self)') == 'func()'
assert (_clean_text_signature('func($self, *args, **kwargs)')
== 'func(*args, **kwargs)')