Target E125 - Continuation line with same indent

https://www.flake8rules.com/rules/E125.html
This commit is contained in:
Stephan Kulow 2022-02-18 15:50:32 +01:00
parent 2023ccbe6e
commit d6628beadf
6 changed files with 34 additions and 24 deletions

View File

@ -1,4 +1,4 @@
[flake8]
exclude = abichecker
max-line-length = 100
ignore = W503,W504,E501,F401,E128,E251,E201,E202,E302,E305,F841,E261,E712,E126,E711,E125
ignore = W503,W504,E501,F401,E128,E251,E201,E202,E302,E305,F841,E261,E712,E126,E711

View File

@ -310,6 +310,18 @@ class ReviewBot(object):
else:
self.logger.debug("%s review not changed" % (req.reqid))
def _is_duplicate_review(self, review, query, allow_duplicate):
if review.by_group != query.get('by_group'):
return False
if review.by_project != query.get('by_project'):
return False
if review.by_package != query.get('by_package'):
return False
if review.by_user != query.get('by_user'):
return False
# Only duplicate when allow_duplicate and state != new.
return (not allow_duplicate or review.state == 'new')
# allow_duplicate=True should only be used if it makes sense to force a
# re-review in a scenario where the bot adding the review will rerun.
# Normally a declined review will automatically be reopened along with the
@ -331,13 +343,8 @@ class ReviewBot(object):
else:
raise osc.oscerr.WrongArgs("missing by_*")
for r in req.reviews:
if (r.by_group == by_group and
r.by_project == by_project and
r.by_package == by_package and
r.by_user == by_user and
# Only duplicate when allow_duplicate and state != new.
(not allow_duplicate or r.state == 'new')):
for review in req.reviews:
if self._is_duplicate_review(review, query, allow_duplicate):
del query['cmd']
self.logger.debug('skipped adding duplicate review for {}'.format(
'/'.join(query.values())))
@ -736,13 +743,7 @@ class ReviewBot(object):
message = self.comment_api.add_marker(message, bot_name, info)
message = self.comment_api.truncate(message.strip())
if (comment is not None and
((identical and
# Remove marker from comments since handled during comment_find().
self.comment_api.remove_marker(comment['comment']) ==
self.comment_api.remove_marker(message)) or
(not identical and comment['comment'].count('\n') == message.count('\n')))
):
if self._is_comment_identical(comment, message, identical):
# Assume same state/result and number of lines in message is duplicate.
self.logger.debug('previous comment too similar on {}'.format(debug_key))
return
@ -764,6 +765,15 @@ class ReviewBot(object):
self.comment_handler_remove()
def _is_comment_identical(self, comment, message, identical):
if comment is None:
return False
if identical:
# Remove marker from comments since handled during comment_find().
return self.comment_api.remove_marker(comment['comment']) == self.comment_api.remove_marker(message)
else:
return comment['comment'].count('\n') == message.count('\n')
def _check_matching_srcmd5(self, project, package, rev, history_limit = 5):
"""check if factory sources contain the package and revision. check head and history"""
self.logger.debug("checking %s in %s" % (package, project))

View File

@ -81,8 +81,8 @@ class MaintenanceChecker(ReviewBot.ReviewBot):
origin = mapping[pkgname]
self.logger.debug("{} comes from {}, submitted from {}".format(pkgname, origin, a.src_project))
if origin.startswith('SUSE:SLE-12') and a.src_project.startswith('SUSE:SLE-12') \
or origin.startswith('SUSE:SLE-15') and a.src_project.startswith('SUSE:SLE-15') \
or origin.startswith('openSUSE:Leap') and a.src_project.startswith('openSUSE:Leap'):
or origin.startswith('SUSE:SLE-15') and a.src_project.startswith('SUSE:SLE-15') \
or origin.startswith('openSUSE:Leap') and a.src_project.startswith('openSUSE:Leap'):
self.logger.info("{} submitted from {}, no maintainer review needed".format(pkgname, a.src_project))
return

View File

@ -158,7 +158,7 @@ def ingest_requests(api, project):
# Staging related reviews.
for number, review in enumerate(
request.xpath('review[contains(@by_project, "{}:Staging:")]'.format(project)), start=1):
request.xpath('review[contains(@by_project, "{}:Staging:")]'.format(project)), start=1):
staged_at = date_parse(review.get('when'))
project_type = 'adi' if api.is_adi_project(review.get('by_project')) else 'letter'

View File

@ -1035,7 +1035,7 @@ def request_create_submit(apiurl, source_project, source_package,
return False
for request, action in request_action_list(
apiurl, target_project, target_package, REQUEST_STATES_MINUS_ACCEPTED, ['submit']):
apiurl, target_project, target_package, REQUEST_STATES_MINUS_ACCEPTED, ['submit']):
if ignore_if_any_request:
return False
if not supersede and request.state.name in ('new', 'review'):
@ -1061,7 +1061,7 @@ def request_create_submit(apiurl, source_project, source_package,
def request_create_delete(apiurl, target_project, target_package, message=None):
for request, action in request_action_list(
apiurl, target_project, target_package, REQUEST_STATES_MINUS_ACCEPTED, ['delete']):
apiurl, target_project, target_package, REQUEST_STATES_MINUS_ACCEPTED, ['delete']):
return False
# No proper API function to perform the same operation.
@ -1078,7 +1078,7 @@ def request_create_change_devel(apiurl, source_project, source_package,
target_package = source_package
for request, action in request_action_list(
apiurl, target_project, target_package, REQUEST_STATES_MINUS_ACCEPTED, ['change_devel']):
apiurl, target_project, target_package, REQUEST_STATES_MINUS_ACCEPTED, ['change_devel']):
return False
message = message_suffix('created', message)

View File

@ -170,7 +170,7 @@ def config_resolve_variable(value, config_project, key='config'):
def config_origin_list(config, apiurl=None, project=None, package=None, skip_workarounds=False):
origin_list = []
for origin, values in config_origin_generator(
config['origins'], apiurl, project, package, skip_workarounds):
config['origins'], apiurl, project, package, skip_workarounds):
origin_list.append(origin)
return origin_list
@ -266,7 +266,7 @@ def origin_find(apiurl, target_project, package, source_hash=None, current=False
def project_source_contain(apiurl, project, package, source_hash):
for source_hash_consider in package_source_hash_history(
apiurl, project, package, include_project_link=True):
apiurl, project, package, include_project_link=True):
project_source_log('contain', project, source_hash_consider, source_hash)
if source_hash_consider == source_hash:
return True
@ -314,7 +314,7 @@ def origin_find_fallback(apiurl, target_project, package, source_hash, user):
# Attempt to find a revision of target package that matches an origin.
first = True
for source_hash_consider in package_source_hash_history(
apiurl, target_project, package, include_project_link=True):
apiurl, target_project, package, include_project_link=True):
if first:
first = False
continue