diff --git a/openstack_releases/cmds/list_changes.py b/openstack_releases/cmds/list_changes.py index 94adc70901..37d4e9c84f 100644 --- a/openstack_releases/cmds/list_changes.py +++ b/openstack_releases/cmds/list_changes.py @@ -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') diff --git a/openstack_releases/cmds/validate.py b/openstack_releases/cmds/validate.py index 8430a894d9..0c2f3a019c 100644 --- a/openstack_releases/cmds/validate.py +++ b/openstack_releases/cmds/validate.py @@ -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' diff --git a/openstack_releases/deliverable.py b/openstack_releases/deliverable.py index 7771680d9e..85da59a910 100644 --- a/openstack_releases/deliverable.py +++ b/openstack_releases/deliverable.py @@ -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 diff --git a/openstack_releases/gitutils.py b/openstack_releases/gitutils.py index 875f76cd29..afc6f01568 100644 --- a/openstack_releases/gitutils.py +++ b/openstack_releases/gitutils.py @@ -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( diff --git a/openstack_releases/rst2txt.py b/openstack_releases/rst2txt.py index 006128695d..a5cf1f8fc0 100644 --- a/openstack_releases/rst2txt.py +++ b/openstack_releases/rst2txt.py @@ -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 diff --git a/openstack_releases/tests/fixtures.py b/openstack_releases/tests/fixtures.py index b275753d70..82d744e07a 100644 --- a/openstack_releases/tests/fixtures.py +++ b/openstack_releases/tests/fixtures.py @@ -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') diff --git a/test-requirements.txt b/test-requirements.txt index 8f12dd2c18..b2c0285ac9 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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 diff --git a/tools/aclmanager.py b/tools/aclmanager.py index 80b706e094..cea6c70a9b 100755 --- a/tools/aclmanager.py +++ b/tools/aclmanager.py @@ -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 diff --git a/tools/discover_branch_points.py b/tools/discover_branch_points.py index 0a48244c1f..8ec55ead28 100755 --- a/tools/discover_branch_points.py +++ b/tools/discover_branch_points.py @@ -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() diff --git a/tools/verify_branches_and_late_releases.py b/tools/verify_branches_and_late_releases.py index 8e73e8b863..0dec477211 100755 --- a/tools/verify_branches_and_late_releases.py +++ b/tools/verify_branches_and_late_releases.py @@ -155,5 +155,6 @@ def main(): return (1 if errors else 0) + if __name__ == '__main__': main() diff --git a/tox.ini b/tox.ini index bce07eb01c..57db79f659 100644 --- a/tox.ini +++ b/tox.ini @@ -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-*