Merge "Update to latest hacking for pep8 checks"

This commit is contained in:
Zuul 2020-08-03 14:01:38 +00:00 committed by Gerrit Code Review
commit 92545dacb0
11 changed files with 32 additions and 34 deletions

View File

@ -601,7 +601,7 @@ def main():
description='',
publishing_dir_name=project.repo.name,
)
except Exception as e:
except Exception:
logging.exception('Failed to produce release notes')
else:
print('\n')

View File

@ -586,8 +586,8 @@ def validate_model(deliv, context):
'no release-model specified',
)
if (deliv.model in ['independent', 'abandoned']
and deliv.series != 'independent'):
if (deliv.model in ['independent', 'abandoned'] and
deliv.series != 'independent'):
# If the project is release:independent or abandoned, make sure
# the deliverable file is in _independent.
context.error(
@ -601,8 +601,8 @@ def validate_model(deliv, context):
# bypass the model property because that always returns
# 'independent' for deliverables in that series.
model_value = deliv.data.get('release-model', 'independent')
if (deliv.series == 'independent'
and model_value not in ['independent', 'abandoned']):
if (deliv.series == 'independent' and
model_value not in ['independent', 'abandoned']):
context.error(
'deliverables in the _independent directory '
'should use either the independent or abandoned release models'

View File

@ -11,8 +11,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Class for manipulating all of the deliverable data.
"""
"""Class for manipulating all of the deliverable data."""
import collections
import copy
@ -60,8 +59,7 @@ def _safe_semver(v):
def _version_sort_key(release):
"""Return a value we can compare for sorting.
"""
"""Return a value we can compare for sorting."""
# NOTE(dhellmann): We want EOL and EM tags to sort last. This assumes we
# won't have more than 1000 major releases of anything, and I
# surely hope that is a safe assumption.
@ -75,7 +73,6 @@ def _collapse_deliverable_history(name, info):
"""Collapse pre-releases into their final release.
Edit the info dictionary in place.
"""
sorted_releases = sorted(
info.get('releases', []),
@ -186,7 +183,6 @@ class Deliverables(object):
deliverable file content.
If the team or series is None, treat that value as a wildcard.
"""
if team is None:
if series is None:
@ -203,8 +199,7 @@ class Deliverables(object):
)
def get_deliverable_history(self, name):
"""Return info associated with a deliverable name.
"""
"""Return info associated with a deliverable name."""
for filename in self._by_deliverable_name.get(name, []):
yield Deliverable(
None, # team will be taken from the data
@ -324,9 +319,9 @@ class Release(object):
@property
def is_pre_release_version(self):
return (
'rc' in self.version
or 'a' in self.version
or 'b' in self.version
'rc' in self.version or
'a' in self.version or
'b' in self.version
)
@property

View File

@ -35,9 +35,9 @@ def find_modified_deliverable_files():
['git', 'diff', '--name-only', '--pretty=format:', 'HEAD^']
).decode('utf-8')
filenames = [
l.strip()
for l in results.splitlines()
if (l.startswith('deliverables/'))
line.strip()
for line in results.splitlines()
if (line.startswith('deliverables/'))
]
return filenames
@ -67,7 +67,6 @@ def commit_exists(workdir, repo, ref):
The commit must have been merged into the repository, but this
check does not enforce any branch membership.
"""
try:
processutils.check_output(
@ -86,14 +85,15 @@ def tag_exists(repo, ref):
Uses a cgit query instead of looking locally to avoid cloning a
repository or having Depends-On settings in a commit message allow
someone to fool the check.
"""
url = GIT_TAG_TEMPLATE % (repo, ref)
return links.link_exists(url)
def ensure_basic_git_config(workdir, repo, settings):
"""Given a repo directory and a settings dict, set local config values
"""Make sure git config is set.
Given a repo directory and a settings dict, set local config values
if those settings are not already defined.
"""
dest = os.path.join(workdir, repo)
@ -132,9 +132,10 @@ def clone_repo(workdir, repo, ref=None, branch=None):
def safe_clone_repo(workdir, repo, ref, messages):
"""Ensure we have a local copy of the repository so we
can scan for values that are more difficult to get
remotely.
"""Clone a git repo and report success or failure.
Ensure we have a local copy of the repository so we can scan for values
that are more difficult to get remotely.
"""
try:
clone_repo(workdir, repo, ref)
@ -178,8 +179,7 @@ def checkout_ref(workdir, repo, ref, messages=None):
def sha_for_tag(workdir, repo, version):
"""Return the SHA for a given tag
"""
"""Return the SHA for a given tag"""
# git log 2.3.11 -n 1 --pretty=format:%H
try:
actual_sha = processutils.check_output(

View File

@ -79,11 +79,11 @@ class TextWrapper(textwrap.TextWrapper):
del chunks[-1]
while chunks:
l = column_width(chunks[-1])
line = column_width(chunks[-1])
if cur_len + l <= width:
if cur_len + line <= width:
cur_line.append(chunks.pop())
cur_len += l
cur_len += line
else:
break

View File

@ -38,7 +38,7 @@ class GPGKeyFixture(fixtures.Fixture):
# value.
self.useFixture(fixtures.TempHomeDir('/tmp'))
tempdir = self.useFixture(fixtures.TempDir('/tmp'))
gnupg_version_re = re.compile('^gpg\s.*\s([\d+])\.([\d+])\.([\d+])')
gnupg_version_re = re.compile(r'^gpg\s.*\s([\d+])\.([\d+])\.([\d+])')
gnupg_version = processutils.check_output(
['gpg', '--version'],
cwd=tempdir.path).decode('utf-8')

View File

@ -2,7 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking>=1.0.0,<1.1.0
hacking>=3.2.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
python-subunit>=0.0.18 # Apache-2.0/BSD

View File

@ -114,7 +114,7 @@ label-Workflow = -1..+1 group {group}
else:
continue
if re.match('^\[access "refs/heads/stable/[a-z]', line):
if re.match(r'^\[access "refs/heads/stable/[a-z]', line):
# We just hit a specific stable section.
# Skip the file until the next section starts.
skip = True

View File

@ -170,5 +170,6 @@ def main():
sys.stderr.write('could not find {} in any repos for {}\n'.format(
branch_name, deliv.name))
if __name__ == '__main__':
main()

View File

@ -155,5 +155,6 @@ def main():
return (1 if errors else 0)
if __name__ == '__main__':
main()

View File

@ -83,8 +83,9 @@ commands =
# E123, E125 skipped as they are invalid PEP-8.
# E501 skipped because some of the code files include templates
# that end up quite wide
# W504 line break after binary operator skipped as it's just wrong
show-source = True
ignore = E123,E125,E501,H405
ignore = E123,E125,E501,W504
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-*