diff --git a/jedi/api/classes.py b/jedi/api/classes.py index 4168f6e9..47cc7a07 100644 --- a/jedi/api/classes.py +++ b/jedi/api/classes.py @@ -536,9 +536,9 @@ class Definition(BaseDefinition): # here. txt = definition.get_code(include_prefix=False) # Delete comments: - txt = re.sub('#[^\n]+\n', ' ', txt) + txt = re.sub(r'#[^\n]+\n', ' ', txt) # Delete multi spaces/newlines - txt = re.sub('\s+', ' ', txt).strip() + txt = re.sub(r'\s+', ' ', txt).strip() return txt @property diff --git a/jedi/evaluate/docstrings.py b/jedi/evaluate/docstrings.py index 86b56673..6fac8b9f 100644 --- a/jedi/evaluate/docstrings.py +++ b/jedi/evaluate/docstrings.py @@ -68,7 +68,7 @@ def _search_param_in_numpydocstr(docstr, param_str): return [] for p_name, p_type, p_descr in params: if p_name == param_str: - m = re.match('([^,]+(,[^,]+)*?)(,[ ]*optional)?$', p_type) + m = re.match(r'([^,]+(,[^,]+)*?)(,[ ]*optional)?$', p_type) if m: p_type = m.group(1) return list(_expand_typestr(p_type)) @@ -103,11 +103,11 @@ def _expand_typestr(type_str): Attempts to interpret the possible types in `type_str` """ # Check if alternative types are specified with 'or' - if re.search('\\bor\\b', type_str): + if re.search(r'\bor\b', type_str): for t in type_str.split('or'): yield t.split('of')[0].strip() # Check if like "list of `type`" and set type to list - elif re.search('\\bof\\b', type_str): + elif re.search(r'\bof\b', type_str): yield type_str.split('of')[0] # Check if type has is a set of valid literal values eg: {'C', 'F', 'A'} elif type_str.startswith('{'): @@ -194,7 +194,7 @@ def _evaluate_for_statement_string(module_context, string): if string is None: return [] - for element in re.findall('((?:\w+\.)*\w+)\.', string): + for element in re.findall(r'((?:\w+\.)*\w+)\.', string): # Try to import module part in dotted name. # (e.g., 'threading' in 'threading.Thread'). string = 'import %s\n' % element + string diff --git a/jedi/evaluate/helpers.py b/jedi/evaluate/helpers.py index 5d3f39d2..c94a1fbe 100644 --- a/jedi/evaluate/helpers.py +++ b/jedi/evaluate/helpers.py @@ -19,7 +19,7 @@ def is_stdlib_path(path): return False base_path = os.path.join(sys.prefix, 'lib', 'python') - return bool(re.match(re.escape(base_path) + '\d.\d', path)) + return bool(re.match(re.escape(base_path) + r'\d.\d', path)) def deep_ast_copy(obj): diff --git a/jedi/evaluate/utils.py b/jedi/evaluate/utils.py index f6d7f870..990a995e 100644 --- a/jedi/evaluate/utils.py +++ b/jedi/evaluate/utils.py @@ -11,7 +11,7 @@ from jedi._compatibility import reraise _sep = os.path.sep if os.path.altsep is not None: _sep += os.path.altsep -_path_re = re.compile('(?:\.[^{0}]+|[{0}]__init__\.py)$'.format(re.escape(_sep))) +_path_re = re.compile(r'(?:\.[^{0}]+|[{0}]__init__\.py)$'.format(re.escape(_sep))) del _sep diff --git a/jedi/utils.py b/jedi/utils.py index 0f42e7d5..1338d1b3 100644 --- a/jedi/utils.py +++ b/jedi/utils.py @@ -138,5 +138,5 @@ def version_info(): """ Version = namedtuple('Version', 'major, minor, micro') from jedi import __version__ - tupl = re.findall('[a-z]+|\d+', __version__) + tupl = re.findall(r'[a-z]+|\d+', __version__) return Version(*[x if i == 3 else int(x) for i, x in enumerate(tupl)])