Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cope with unexpected signature #277

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion numpydoc/numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions numpydoc/tests/test_numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)')
Expand Down