Skip to content

Commit b56921a

Browse files
committed
Manually fix remaining flake8 failures in easybuild/tools
1 parent 6d15cd6 commit b56921a

File tree

7 files changed

+21
-22
lines changed

7 files changed

+21
-22
lines changed

easybuild/tools/configobj.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def __init__(self, section):
319319

320320
def interpolate(self, key, value):
321321
# short-cut
322-
if not self._cookie in value:
322+
if self._cookie not in value:
323323
return value
324324

325325
def recursive_interpolate(key, value, section, backtrail):
@@ -543,7 +543,7 @@ def _interpolate(self, key, value):
543543
except AttributeError:
544544
# not yet: first time running _interpolate(), so pick the engine
545545
name = self.main.interpolation
546-
if name == True: # note that "if name:" would be incorrect here
546+
if name is True: # note that "if name:" would be incorrect here
547547
# backwards-compatibility: interpolation=True means use default
548548
name = DEFAULT_INTERPOLATION
549549
name = name.lower() # so that "Template", "template", etc. all work
@@ -942,10 +942,8 @@ def as_bool(self, key):
942942
0
943943
"""
944944
val = self[key]
945-
if val == True:
946-
return True
947-
elif val == False:
948-
return False
945+
if val is True or val is False:
946+
return val
949947
else:
950948
try:
951949
if not isinstance(val, string_type):
@@ -1466,7 +1464,7 @@ def _decode(self, infile, encoding):
14661464
# NOTE: Could raise a ``UnicodeDecodeError``
14671465
return infile.decode(encoding).splitlines(True)
14681466
for i, line in enumerate(infile):
1469-
if not isinstance(line, unicode):
1467+
if isinstance(line, str):
14701468
# NOTE: The isinstance test here handles mixed lists of unicode/string
14711469
# NOTE: But the decode will break on any non-string values
14721470
# NOTE: Or could raise a ``UnicodeDecodeError``
@@ -2175,7 +2173,7 @@ def validate_entry(entry, spec, val, missing, ret_true, ret_false):
21752173
if entry in ('__many__', '___many___'):
21762174
# reserved names
21772175
continue
2178-
if (not entry in section.scalars) or (entry in section.defaults):
2176+
if (entry not in section.scalars) or (entry in section.defaults):
21792177
# missing entries
21802178
# or entries from defaults
21812179
missing = True
@@ -2238,9 +2236,9 @@ def validate_entry(entry, spec, val, missing, ret_true, ret_false):
22382236
section.inline_comments[entry] = configspec.inline_comments.get(entry, '')
22392237
check = self.validate(validator, preserve_errors=preserve_errors, copy=copy, section=section[entry])
22402238
out[entry] = check
2241-
if check == False:
2239+
if check is False:
22422240
ret_true = False
2243-
elif check == True:
2241+
elif check is True:
22442242
ret_false = False
22452243
else:
22462244
ret_true = False
@@ -2356,15 +2354,15 @@ def flatten_errors(cfg, res, levels=None, results=None):
23562354
# first time called
23572355
levels = []
23582356
results = []
2359-
if res == True:
2357+
if res is True:
23602358
return results
2361-
if res == False or isinstance(res, Exception):
2359+
if res is False or isinstance(res, Exception):
23622360
results.append((levels[:], None, res))
23632361
if levels:
23642362
levels.pop()
23652363
return results
23662364
for (key, val) in res.items():
2367-
if val == True:
2365+
if val is True:
23682366
continue
23692367
if isinstance(cfg.get(key), dict):
23702368
# Go down one level

easybuild/tools/filetools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1843,7 +1843,7 @@ def copytree(src, dst, symlinks=False, ignore=None):
18431843
class Error(EnvironmentError):
18441844
pass
18451845
try:
1846-
WindowsError # @UndefinedVariable
1846+
WindowsError = WindowsError # noqa
18471847
except NameError:
18481848
WindowsError = None
18491849

easybuild/tools/job/gc3pie.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class AbortingDependentTaskCollection(AbortOnError, DependentTaskCollection):
6969
"""
7070
pass
7171

72-
except ImportError as err:
72+
except ImportError:
7373
_log.debug("Failed to import gc3libs from GC3Pie."
7474
" Silently ignoring, this is a real issue only when GC3Pie is used as backend for --job")
7575

easybuild/tools/job/pbs_python.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
from PBSQuery import PBSQuery
5555
KNOWN_HOLD_TYPES = [pbs.USER_HOLD, pbs.OTHER_HOLD, pbs.SYSTEM_HOLD]
5656

57-
except ImportError as err:
57+
except ImportError:
5858
_log.debug("Failed to import pbs/PBSQuery from pbs_python."
5959
" Silently ignoring, this is a real issue only when pbs_python is used as backend for --job")
6060

@@ -347,7 +347,8 @@ def _submit(self):
347347

348348
self.log.debug("Going to submit to queue %s" % self.queue)
349349

350-
# job submission sometimes fails without producing an error, e.g. when one of the dependency jobs has already finished
350+
# job submission sometimes fails without producing an error,
351+
# e.g. when one of the dependency jobs has already finished
351352
# when that occurs, None will be returned by pbs_submit as job id
352353
jobid = pbs.pbs_submit(self.pbsconn, pbs_attributes, scriptfn, self.queue, NULL)
353354
is_error, errormsg = pbs.error()

easybuild/tools/py2vs3/py2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def subprocess_popen_text(cmd, **kwargs):
6565

6666
def raise_with_traceback(exception_class, message, traceback):
6767
"""Raise exception of specified class with given message and traceback."""
68-
raise exception_class, message, traceback
68+
raise exception_class, message, traceback # noqa: E999
6969

7070

7171
def extract_method_name(method_func):

easybuild/tools/repository/hgrepo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def create_working_copy(self):
100100

101101
# try to get a copy of
102102
try:
103-
client = hglib.clone(self.repo, self.wc)
103+
hglib.clone(self.repo, self.wc)
104104
self.log.debug("repo %s cloned in %s" % (self.repo, self.wc))
105105
except (HgCommandError, OSError) as err:
106106
# it might already have existed

easybuild/tools/variables.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ def __init__(self, *args, **kwargs):
225225

226226
self.protected_classes = self.PROTECTED_CLASSES[:]
227227
if self.PROTECT_CLASS_SELF:
228-
if not self.DEFAULT_CLASS in self.protected_classes:
228+
if self.DEFAULT_CLASS not in self.protected_classes:
229229
self.protected_classes.append(self.DEFAULT_CLASS)
230230
self.protected_instances = self.PROTECTED_INSTANCES[:]
231231
if self.PROTECT_INSTANCE_SELF:
232-
if not self.DEFAULT_CLASS in self.protected_instances:
232+
if self.DEFAULT_CLASS not in self.protected_instances:
233233
self.protected_instances.append(self.DEFAULT_CLASS)
234234

235235
def append_empty(self):
@@ -291,7 +291,7 @@ def nappend(self, value, **kwargs):
291291
newvalue = klass(**kwargs)
292292
if value is not None:
293293
newvalue.append(value)
294-
if not position is None:
294+
if position is not None:
295295
newvalue.POSITION = position
296296
if self._str_ok(newvalue) or append_empty:
297297
self.append(newvalue)

0 commit comments

Comments
 (0)