flake8: fix flake8 issues with invalid escapes

- in many files, regular strings were used in places where raw strings
  should've been used.

- convert these to raw strings and get rid of new flake8 errors
This commit is contained in:
Todd Gamblin
2018-12-31 23:25:40 -08:00
parent 6f50cd52ed
commit 5425a3dad4
22 changed files with 161 additions and 148 deletions

View File

@@ -171,7 +171,7 @@ def __init__(self, root, **kwargs):
"${COMPILERNAME}-${COMPILERVER}/"
"${PACKAGE}-${VERSION}-${HASH}")
if self.hash_len is not None:
if re.search('\${HASH:\d+}', self.path_scheme):
if re.search(r'\${HASH:\d+}', self.path_scheme):
raise InvalidDirectoryLayoutParametersError(
"Conflicting options for installation layout hash length")
self.path_scheme = self.path_scheme.replace(

View File

@@ -3,7 +3,7 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
"""Functions for graphing DAGs of dependencies.
r"""Functions for graphing DAGs of dependencies.
This file contains code for graphing DAGs of software packages
(i.e. Spack specs). There are two main functions you probably care

View File

@@ -120,7 +120,7 @@ def macho_get_paths(path_name):
if match:
lhs = match.group(1).lstrip().rstrip()
rhs = match.group(2)
match2 = re.search('(.*) \(.*\)', rhs)
match2 = re.search(r'(.*) \(.*\)', rhs)
if match2:
rhs = match2.group(1)
if lhs == 'cmd':

View File

@@ -61,8 +61,8 @@ def test_verify(tmpdir):
assert str(old_lgpl_header) in out
assert str(correct_header) not in out
assert '3 improperly licensed files' in out
assert re.search('files with no SPDX-License-Identifier:\s*1', out)
assert re.search('files with wrong SPDX-License-Identifier:\s*1', out)
assert re.search('files with old license header:\s*1', out)
assert re.search(r'files with no SPDX-License-Identifier:\s*1', out)
assert re.search(r'files with wrong SPDX-License-Identifier:\s*1', out)
assert re.search(r'files with old license header:\s*1', out)
assert license.returncode == 1

View File

@@ -15,10 +15,10 @@ class Base:
counter = 0
def add(self):
raise NotImplemented('add not implemented')
raise NotImplementedError('add not implemented')
def subtract(self):
raise NotImplemented('subtract not implemented')
raise NotImplementedError('subtract not implemented')
return Base

View File

@@ -44,7 +44,7 @@
# "path" seemed like the most generic term.
#
def find_list_url(url):
"""Finds a good list URL for the supplied URL.
r"""Finds a good list URL for the supplied URL.
By default, returns the dirname of the archive path.
@@ -148,81 +148,81 @@ def strip_version_suffixes(path):
suffix_regexes = [
# Download type
'[Ii]nstall',
'all',
'code',
'src(_0)?',
'[Ss]ources?',
'file',
'full',
'single',
'public',
'with[a-zA-Z_-]+',
'bin',
'binary',
'run',
'[Uu]niversal',
'jar',
'complete',
'dynamic',
'oss',
'gem',
'tar',
'sh',
r'[Ii]nstall',
r'all',
r'code',
r'src(_0)?',
r'[Ss]ources?',
r'file',
r'full',
r'single',
r'public',
r'with[a-zA-Z_-]+',
r'bin',
r'binary',
r'run',
r'[Uu]niversal',
r'jar',
r'complete',
r'dynamic',
r'oss',
r'gem',
r'tar',
r'sh',
# Download version
'release',
'stable',
'[Ff]inal',
'rel',
'orig',
'dist',
'\+',
r'release',
r'stable',
r'[Ff]inal',
r'rel',
r'orig',
r'dist',
r'\+',
# License
'gpl',
r'gpl',
# Arch
# Needs to come before and after OS, appears in both orders
'ia32',
'intel',
'amd64',
'x64',
'x86[_-]64',
'x86',
'i[36]86',
'ppc64(le)?',
'armv?(7l|6l|64)',
r'ia32',
r'intel',
r'amd64',
r'x64',
r'x86[_-]64',
r'x86',
r'i[36]86',
r'ppc64(le)?',
r'armv?(7l|6l|64)',
# OS
'[Ll]inux(_64)?',
'[Uu]ni?x',
'[Ss]un[Oo][Ss]',
'[Mm]ac[Oo][Ss][Xx]?',
'[Oo][Ss][Xx]',
'[Dd]arwin(64)?',
'[Aa]pple',
'[Ww]indows',
'[Ww]in(64|32)?',
'[Cc]ygwin(64|32)?',
'[Mm]ingw',
r'[Ll]inux(_64)?',
r'[Uu]ni?x',
r'[Ss]un[Oo][Ss]',
r'[Mm]ac[Oo][Ss][Xx]?',
r'[Oo][Ss][Xx]',
r'[Dd]arwin(64)?',
r'[Aa]pple',
r'[Ww]indows',
r'[Ww]in(64|32)?',
r'[Cc]ygwin(64|32)?',
r'[Mm]ingw',
# Arch
# Needs to come before and after OS, appears in both orders
'ia32',
'intel',
'amd64',
'x64',
'x86[_-]64',
'x86',
'i[36]86',
'ppc64(le)?',
'armv?(7l|6l|64)?',
r'ia32',
r'intel',
r'amd64',
r'x64',
r'x86[_-]64',
r'x86',
r'i[36]86',
r'ppc64(le)?',
r'armv?(7l|6l|64)?',
# PyPI
'[._-]py[23].*\.whl',
'[._-]cp[23].*\.whl',
'[._-]win.*\.exe',
r'[._-]py[23].*\.whl',
r'[._-]cp[23].*\.whl',
r'[._-]win.*\.exe',
]
for regex in suffix_regexes:
@@ -274,22 +274,22 @@ def strip_name_suffixes(path, version):
str(version) + '.*',
# Download type
'install',
'src',
'(open)?[Ss]ources?',
'[._-]archive',
'[._-]std',
r'install',
r'src',
r'(open)?[Ss]ources?',
r'[._-]archive',
r'[._-]std',
# Download version
'release',
'snapshot',
'distrib',
r'release',
r'snapshot',
r'distrib',
# VCS
'0\+bzr',
r'0\+bzr',
# License
'gpl',
r'gpl',
]
for regex in suffix_regexes:
@@ -799,7 +799,7 @@ def wildcard_version(path):
# Replace each version with a generic capture group to find versions
# and escape everything else so it's not interpreted as a regex
result = '(\d.*)'.join(re.escape(vp) for vp in vparts)
result = r'(\d.*)'.join(re.escape(vp) for vp in vparts)
return result