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='', description='',
publishing_dir_name=project.repo.name, publishing_dir_name=project.repo.name,
) )
except Exception as e: except Exception:
logging.exception('Failed to produce release notes') logging.exception('Failed to produce release notes')
else: else:
print('\n') print('\n')

View File

@ -586,8 +586,8 @@ def validate_model(deliv, context):
'no release-model specified', 'no release-model specified',
) )
if (deliv.model in ['independent', 'abandoned'] if (deliv.model in ['independent', 'abandoned'] and
and deliv.series != 'independent'): deliv.series != 'independent'):
# If the project is release:independent or abandoned, make sure # If the project is release:independent or abandoned, make sure
# the deliverable file is in _independent. # the deliverable file is in _independent.
context.error( context.error(
@ -601,8 +601,8 @@ def validate_model(deliv, context):
# bypass the model property because that always returns # bypass the model property because that always returns
# 'independent' for deliverables in that series. # 'independent' for deliverables in that series.
model_value = deliv.data.get('release-model', 'independent') model_value = deliv.data.get('release-model', 'independent')
if (deliv.series == 'independent' if (deliv.series == 'independent' and
and model_value not in ['independent', 'abandoned']): model_value not in ['independent', 'abandoned']):
context.error( context.error(
'deliverables in the _independent directory ' 'deliverables in the _independent directory '
'should use either the independent or abandoned release models' '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 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
"""Class for manipulating all of the deliverable data. """Class for manipulating all of the deliverable data."""
"""
import collections import collections
import copy import copy
@ -60,8 +59,7 @@ def _safe_semver(v):
def _version_sort_key(release): 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 # 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 # won't have more than 1000 major releases of anything, and I
# surely hope that is a safe assumption. # surely hope that is a safe assumption.
@ -75,7 +73,6 @@ def _collapse_deliverable_history(name, info):
"""Collapse pre-releases into their final release. """Collapse pre-releases into their final release.
Edit the info dictionary in place. Edit the info dictionary in place.
""" """
sorted_releases = sorted( sorted_releases = sorted(
info.get('releases', []), info.get('releases', []),
@ -186,7 +183,6 @@ class Deliverables(object):
deliverable file content. deliverable file content.
If the team or series is None, treat that value as a wildcard. If the team or series is None, treat that value as a wildcard.
""" """
if team is None: if team is None:
if series is None: if series is None:
@ -203,8 +199,7 @@ class Deliverables(object):
) )
def get_deliverable_history(self, name): 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, []): for filename in self._by_deliverable_name.get(name, []):
yield Deliverable( yield Deliverable(
None, # team will be taken from the data None, # team will be taken from the data
@ -324,9 +319,9 @@ class Release(object):
@property @property
def is_pre_release_version(self): def is_pre_release_version(self):
return ( return (
'rc' in self.version 'rc' in self.version or
or 'a' in self.version 'a' in self.version or
or 'b' in self.version 'b' in self.version
) )
@property @property

View File

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

View File

@ -79,11 +79,11 @@ class TextWrapper(textwrap.TextWrapper):
del chunks[-1] del chunks[-1]
while chunks: 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_line.append(chunks.pop())
cur_len += l cur_len += line
else: else:
break break

View File

@ -38,7 +38,7 @@ class GPGKeyFixture(fixtures.Fixture):
# value. # value.
self.useFixture(fixtures.TempHomeDir('/tmp')) self.useFixture(fixtures.TempHomeDir('/tmp'))
tempdir = self.useFixture(fixtures.TempDir('/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( gnupg_version = processutils.check_output(
['gpg', '--version'], ['gpg', '--version'],
cwd=tempdir.path).decode('utf-8') cwd=tempdir.path).decode('utf-8')

View File

@ -2,7 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # 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 fixtures>=3.0.0 # Apache-2.0/BSD
python-subunit>=0.0.18 # 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: else:
continue 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. # We just hit a specific stable section.
# Skip the file until the next section starts. # Skip the file until the next section starts.
skip = True skip = True

View File

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

View File

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

View File

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