Skip to content

Commit

Permalink
fixes for pylint 1.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tardyp committed May 23, 2017
1 parent 0599b94 commit 648ca88
Show file tree
Hide file tree
Showing 85 changed files with 1,079 additions and 524 deletions.
622 changes: 618 additions & 4 deletions common/code_spelling_ignore_words.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions master/buildbot/buildbot_net_usage_data.py
Expand Up @@ -71,8 +71,8 @@ def get_distro():
elif system == "Darwin":
dist = platform.mac_ver()
return "{}".format(dist[0])
else:
return ":".join(platform.uname()[0:1])
# else:
return ":".join(platform.uname()[0:1])


def getName(obj):
Expand Down
3 changes: 1 addition & 2 deletions master/buildbot/changes/gerritchangesource.py
Expand Up @@ -156,8 +156,7 @@ def getGroupingPolicyFromEvent(self, event):
if event['type'] in ('patchset-created',):
return "%s/%s" % (event_change["branch"],
event_change['number'])
else:
return event_change["branch"]
return event_change["branch"]

def addChangeFromEvent(self, properties, event):

Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/changes/github.py
Expand Up @@ -250,7 +250,7 @@ def _processChanges(self, github_result):
failures[0].raiseException()
[files, email] = [r[1] for r in results]

if email is not None and email is not "null":
if email is not None and email != "null":
author += " <" + str(email) + ">"

properties = self.extractProperties(pr)
Expand Down
9 changes: 4 additions & 5 deletions master/buildbot/changes/gitpoller.py
Expand Up @@ -80,7 +80,7 @@ def __init__(self, repourl, branches=None, branch=None,
branches = [branch]
elif not branches:
if only_tags:
branches = lambda ref: ref.startswith('refs/tags/')
branches = lambda ref: ref.startswith('refs/tags/') # noqa: E731
else:
branches = ['master']

Expand Down Expand Up @@ -231,8 +231,7 @@ def process(git_output):
'gitpoller: caught exception converting output \'%s\' to timestamp' % git_output)
raise e
return stamp
else:
return None
return None
return d

def _get_commit_files(self, rev):
Expand Down Expand Up @@ -261,7 +260,7 @@ def _get_commit_author(self, rev):
@d.addCallback
def process(git_output):
git_output = self._decode(git_output)
if len(git_output) == 0:
if not git_output:
raise EnvironmentError('could not get commit author for rev')
return git_output
return d
Expand Down Expand Up @@ -307,7 +306,7 @@ def _process_changes(self, newRev, branch):
revList = results.split()
revList.reverse()

if rebuild and len(revList) == 0:
if rebuild and not revList:
revList = [newRev]

self.changeCount = len(revList)
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/changes/mail.py
Expand Up @@ -416,7 +416,8 @@ def parse(self, m, prefix=None):
# https://code.launchpad.net/~knielsen/maria/tmp-buildbot-test
#
# You are subscribed to branch lp:~knielsen/maria/tmp-buildbot-test.
# To unsubscribe from this branch go to https://code.launchpad.net/~knielsen/maria/tmp-buildbot-test/+edit-subscription.
# To unsubscribe from this branch go to
# https://code.launchpad.net/~knielsen/maria/tmp-buildbot-test/+edit-subscription.
#
# [end of mail]

Expand Down Expand Up @@ -532,8 +533,7 @@ def gobble_renamed(s):
comments=d['comments'],
when=when, revision=rev,
branch=branch, repository=repository or ''))
else:
return None
return None


def parseLaunchpadDate(datestr, tz_sign, tz_hours, tz_minutes):
Expand Down
3 changes: 1 addition & 2 deletions master/buildbot/changes/pb.py
Expand Up @@ -172,8 +172,7 @@ def _unregister(self):
reg = self.registration
self.registration = None
return reg.unregister()
else:
return defer.succeed(None)
return defer.succeed(None)

def getPerspective(self, mind, username):
assert username == self.user
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/changes/svnpoller.py
Expand Up @@ -54,8 +54,7 @@ def split_file_branches(path):
return (None, '/'.join(pieces[1:]))
elif len(pieces) > 2 and pieces[0] == 'branches':
return ('/'.join(pieces[0:2]), '/'.join(pieces[2:]))
else:
return None
return None


def split_file_projects_branches(path):
Expand Down Expand Up @@ -402,7 +401,8 @@ def create_changes(self, new_logentries):
branch]['number_of_directories']
number_of_files_changed = len(files)

if action == u'D' and number_of_directories_changed == 1 and number_of_files_changed == 1 and files[0] == '':
if (action == u'D' and number_of_directories_changed == 1 and
number_of_files_changed == 1 and files[0] == ''):
log.msg("Ignoring deletion of branch '%s'" % branch)
else:
chdict = dict(
Expand Down
7 changes: 3 additions & 4 deletions master/buildbot/data/base.py
Expand Up @@ -161,10 +161,9 @@ def __eq__(self, other):
and self.offset == other.offset \
and self.total == other.total \
and self.limit == other.limit
else:
return self.data == other \
and self.offset == self.limit is None \
and (self.total is None or self.total == len(other))
return self.data == other \
and self.offset == self.limit is None \
and (self.total is None or self.total == len(other))

def __ne__(self, other):
return not (self == other)
Expand Down
10 changes: 4 additions & 6 deletions master/buildbot/data/resultspec.py
Expand Up @@ -114,8 +114,7 @@ def __lt__(self, other):
return True
elif other.value is None:
return False
else:
return self.value < other.value
return self.value < other.value

def __eq__(self, other):
return self.value == other.value
Expand All @@ -130,8 +129,7 @@ def __gt_(self, other):
return False
elif other.value is None:
return True
else:
return self.value < other.value
return self.value < other.value


class ReverseComparator(object):
Expand Down Expand Up @@ -175,8 +173,8 @@ def __init__(self, filters=None, fields=None, properties=None, order=None,
def __repr__(self):
return ("ResultSpec(**{{'filters': {}, 'fields': {}, 'properties': {}, "
"'order': {}, 'limit': {}, 'offset': {}").format(
self.filters, self.fields, self.properties, self.order,
self.limit, self.offset) + "})"
self.filters, self.fields, self.properties, self.order,
self.limit, self.offset) + "})"

def __eq__(self, b):
for i in ['filters', 'fields', 'properties', 'order', 'limit', 'offset']:
Expand Down
12 changes: 8 additions & 4 deletions master/buildbot/data/types.py
Expand Up @@ -50,8 +50,7 @@ def cmp(self, val, arg):
return -1
elif val == argVal:
return 0
else:
return 1
return 1

def validate(self, name, object):
raise NotImplementedError
Expand Down Expand Up @@ -172,7 +171,7 @@ def __init__(self, len=None, **kwargs):

def valueFromString(self, arg):
val = util.bytes2unicode(arg)
if not self.identRe.match(val) or not 0 < len(val) <= self.len:
if not self.identRe.match(val) or len(val) > self.len or not val:
raise TypeError
return val

Expand Down Expand Up @@ -390,4 +389,9 @@ def getSpec(self):

def toRaml(self):
return {'type': "object",
'properties': dict([(maybeNoneOrList(k, v), {'type': v.ramlname, 'description': ''}) for k, v in iteritems(self.fields)])}
'properties': dict([
(
maybeNoneOrList(k, v),
{'type': v.ramlname, 'description': ''}
)
for k, v in iteritems(self.fields)])}
3 changes: 1 addition & 2 deletions master/buildbot/db/base.py
Expand Up @@ -97,8 +97,7 @@ def encode(x):
return b'\xf5'
elif isinstance(x, text_type):
return x.encode('utf-8')
else:
return str(x).encode('utf-8')
return str(x).encode('utf-8')

return hashlib.sha1(b'\0'.join(map(encode, args))).hexdigest()

Expand Down
12 changes: 5 additions & 7 deletions master/buildbot/db/builders.py
Expand Up @@ -41,9 +41,8 @@ def updateBuilderInfo(self, builderid, description, tags):
def toTagid(tag):
if isinstance(tag, type(1)):
return defer.succeed(tag)
else:
ssConnector = self.master.db.tags
return ssConnector.findTagId(tag)
ssConnector = self.master.db.tags
return ssConnector.findTagId(tag)

tagsids = [r[1] for r in (yield defer.DeferredList(
[toTagid(tag) for tag in tags],
Expand Down Expand Up @@ -79,8 +78,7 @@ def getBuilder(self, builderid):
def first(bldrs):
if bldrs:
return bldrs[0]
else:
return None
return None
return d

def addBuilderMaster(self, builderid=None, masterid=None):
Expand All @@ -97,8 +95,8 @@ def removeBuilderMaster(self, builderid=None, masterid=None):
def thd(conn, no_recurse=False):
tbl = self.db.model.builder_masters
conn.execute(tbl.delete(
whereclause=((tbl.c.builderid == builderid)
& (tbl.c.masterid == masterid))))
whereclause=((tbl.c.builderid == builderid) &
(tbl.c.masterid == masterid))))
return self.db.pool.do(thd)

def getBuilders(self, masterid=None, _builderid=None):
Expand Down
5 changes: 2 additions & 3 deletions master/buildbot/db/buildsets.py
Expand Up @@ -59,9 +59,8 @@ def addBuildset(self, sourcestamps, reason, properties, builderids,
def toSsid(sourcestamp):
if isinstance(sourcestamp, integer_types):
return defer.succeed(sourcestamp)
else:
ssConnector = self.master.db.sourcestamps
return ssConnector.findSourceStampId(**sourcestamp)
ssConnector = self.master.db.sourcestamps
return ssConnector.findSourceStampId(**sourcestamp)
sourcestamps = yield defer.DeferredList(
[toSsid(ss) for ss in sourcestamps],
fireOnOneErrback=True, consumeErrors=True)
Expand Down
3 changes: 1 addition & 2 deletions master/buildbot/db/logs.py
Expand Up @@ -245,8 +245,7 @@ def _splitBigChunk(self, content, logid):
i = content.find(b'\n', self.MAX_CHUNK_SIZE)
if i == -1:
return truncline, None
else:
return truncline, content[i + 1:]
return truncline, content[i + 1:]

def finishLog(self, logid):
def thdfinishLog(conn):
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/db/schedulers.py
Expand Up @@ -45,13 +45,13 @@ def thd(conn):
tbl = self.db.model.scheduler_changes
ins_q = tbl.insert()
upd_q = tbl.update(
((tbl.c.schedulerid == schedulerid)
& (tbl.c.changeid == sa.bindparam('wc_changeid'))))
((tbl.c.schedulerid == schedulerid) &
(tbl.c.changeid == sa.bindparam('wc_changeid'))))
for changeid, important in iteritems(classifications):
transaction = conn.begin()
# convert the 'important' value into an integer, since that
# is the column type
imp_int = important and 1 or 0
imp_int = int(bool(important))
try:
conn.execute(ins_q,
schedulerid=schedulerid,
Expand Down
8 changes: 4 additions & 4 deletions master/buildbot/locks.py
Expand Up @@ -29,7 +29,8 @@
if False: # for debugging pylint: disable=using-constant-test
debuglog = log.msg
else:
debuglog = lambda m: None
def debuglog(m):
pass


class BaseLock:
Expand Down Expand Up @@ -96,9 +97,8 @@ def isAvailable(self, requester, access):
# Wants counting access
return num_excl == 0 and num_counting + len(ahead) < self.maxCount \
and all([w[1].mode == 'counting' for w in ahead])
else:
# Wants exclusive access
return num_excl == 0 and num_counting == 0 and len(ahead) == 0
# else Wants exclusive access
return num_excl == 0 and num_counting == 0 and not ahead

def claim(self, owner, access):
""" Claim the lock (lock must be available) """
Expand Down
5 changes: 2 additions & 3 deletions master/buildbot/monkeypatches/python14653.py
Expand Up @@ -24,9 +24,8 @@ def fixed_mktime_tz(data):
if data[9] is None:
# No zone info, so localtime is better assumption than GMT
return time.mktime(data[:8] + (-1,))
else:
t = calendar.timegm(data)
return t - data[9]
t = calendar.timegm(data)
return t - data[9]


def patch():
Expand Down
5 changes: 2 additions & 3 deletions master/buildbot/pbmanager.py
Expand Up @@ -208,6 +208,5 @@ def check(matched):
return failure.Failure(error.UnauthorizedLogin())
return creds.username
return d
else:
log.msg("invalid login from unknown user '%s'" % creds.username)
return defer.fail(error.UnauthorizedLogin())
log.msg("invalid login from unknown user '%s'" % creds.username)
return defer.fail(error.UnauthorizedLogin())
5 changes: 2 additions & 3 deletions master/buildbot/plugins/db.py
Expand Up @@ -149,7 +149,7 @@ def load(self):

def add(self, name, entry):
assert isinstance(name, string_types) and isinstance(entry,
_PluginEntry)
_PluginEntry)
self._add(name, entry)

def _add(self, name, entry):
Expand Down Expand Up @@ -183,8 +183,7 @@ def __getattr__(self, name):

if isinstance(child, _PluginEntry):
return child.value
else:
return child
return child

def info(self, name):
assert isinstance(name, string_types)
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/process/botmaster.py
Expand Up @@ -103,7 +103,7 @@ def cleanShutdown(self, quickMode=False, stopReactor=True, _reactor=reactor):
for builder in self.builders.values():
for build in builder.building:
l.append(build.waitUntilFinished())
if len(l) == 0:
if not l:
log.msg("No running jobs, starting shutdown immediately")
else:
log.msg("Waiting for %i build(s) to finish" % len(l))
Expand Down
3 changes: 1 addition & 2 deletions master/buildbot/process/build.py
Expand Up @@ -673,8 +673,7 @@ def getSummaryStatistic(self, name, summary_fn, initial_value=_sentinel):
if st.hasStatistic(name)]
if initial_value is self._sentinel:
return reduce(summary_fn, step_stats_list)
else:
return reduce(summary_fn, step_stats_list, initial_value)
return reduce(summary_fn, step_stats_list, initial_value)

@defer.inlineCallbacks
def getUrl(self):
Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/process/builder.py
Expand Up @@ -333,7 +333,7 @@ def _startBuildFor(self, workerforbuilder, buildrequests):
# set up locks
build.setLocks(self.config.locks)

if len(self.config.env) > 0:
if self.config.env:
build.setWorkerEnvironment(self.config.env)

# append the build to self.building
Expand Down Expand Up @@ -374,7 +374,7 @@ def _startBuildFor(self, workerforbuilder, buildrequests):

def setupProperties(self, props):
props.setProperty("buildername", self.name, "Builder")
if len(self.config.properties) > 0:
if self.config.properties:
for propertyname in self.config.properties:
props.setProperty(propertyname,
self.config.properties[propertyname],
Expand Down
3 changes: 1 addition & 2 deletions master/buildbot/process/buildrequest.py
Expand Up @@ -309,8 +309,7 @@ def mergeSourceStampsWith(self, others):
for other in others:
if codebase in other.sources:
all_sources.append(other.sources[codebase])
assert len(
all_sources) > 0, "each codebase should have atleast one sourcestamp"
assert all_sources, "each codebase should have atleast one sourcestamp"

# TODO: select the sourcestamp that best represents the merge,
# preferably the latest one. This used to be accomplished by
Expand Down

0 comments on commit 648ca88

Please sign in to comment.