Skip to content

FIX deprecated use of string escapes #182

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

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 5 additions & 5 deletions numpydoc/docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, data):
Parameters
----------
data : str
String with lines separated by '\n'.
String with lines separated by '\\n'.

"""
if isinstance(data, list):
Expand Down Expand Up @@ -317,7 +317,7 @@ def _parse_summary(self):
while True:
summary = self._doc.read_to_next_empty_line()
summary_str = " ".join([s.strip() for s in summary]).strip()
if re.compile('^([\w., ]+=)?\s*[\w\.]+\(.*\)$').match(summary_str):
if re.compile(r'^([\w., ]+=)?\s*[\w\.]+\(.*\)$').match(summary_str):
self['Signature'] = summary_str
if not self._is_at_section():
continue
Expand Down Expand Up @@ -389,7 +389,7 @@ def _str_indent(self, doc, indent=4):

def _str_signature(self):
if self['Signature']:
return [self['Signature'].replace('*', '\*')] + ['']
return [self['Signature'].replace('*', r'\*')] + ['']
else:
return ['']

Expand Down Expand Up @@ -521,7 +521,7 @@ def __init__(self, func, role='func', doc=None, config={}):
else:
argspec = inspect.getargspec(func)
signature = inspect.formatargspec(*argspec)
signature = '%s%s' % (func_name, signature.replace('*', '\*'))
signature = '%s%s' % (func_name, signature.replace('*', r'\*'))
except TypeError:
signature = '%s()' % func_name
self['Signature'] = signature
Expand All @@ -538,7 +538,7 @@ def __str__(self):
out = ''

func, func_name = self.get_func()
signature = self['Signature'].replace('*', '\*')
signature = self['Signature'].replace('*', r'\*')

roles = {'func': 'function',
'meth': 'method'}
Expand Down
2 changes: 1 addition & 1 deletion numpydoc/docscrape_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def _process_param(self, param, desc, fake_autosummary):
param)
if obj_doc:
# Overwrite desc. Take summary logic of autosummary
desc = re.split('\n\s*\n', obj_doc.strip(), 1)[0]
desc = re.split(r'\n\s*\n', obj_doc.strip(), 1)[0]
# XXX: Should this have DOTALL?
# It does not in autosummary
m = re.search(r"^([A-Z].*?\.)(?:\s|$)",
Expand Down
6 changes: 3 additions & 3 deletions numpydoc/tests/test_docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,13 +632,13 @@ def test_parameters_without_extended_description():

def test_escape_stars():
signature = str(doc3).split('\n')[0]
assert_equal(signature, 'my_signature(\*params, \*\*kwds)')
assert_equal(signature, r'my_signature(\*params, \*\*kwds)')

def my_func(a, b, **kwargs):
pass

fdoc = FunctionDoc(func=my_func)
assert_equal(fdoc['Signature'], 'my_func(a, b, \*\*kwargs)')
assert_equal(fdoc['Signature'], r'my_func(a, b, \*\*kwargs)')


doc4 = NumpyDocString(
Expand Down Expand Up @@ -1238,7 +1238,7 @@ def test_args_and_kwargs():
**kwargs : dict
Keyword arguments
""", config=cfg)
line_by_line_compare(str(doc), """
line_by_line_compare(str(doc), r"""
:Parameters:

**param1** : int
Expand Down