From: Andrew Grimberg Date: Mon, 28 Jun 2021 17:28:24 +0000 (-0700) Subject: Chore: Upgrade pre-commit hooks X-Git-Tag: v0.35.2~4 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F60%2F68160%2F2;p=releng%2Flftools.git Chore: Upgrade pre-commit hooks This change also includes style updates enforced by black that have to come in _with_ the upgrade. Change-Id: I68eebed11c5aca19d530104ae1164c42371d4851 Signed-off-by: Andrew Grimberg --- diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0b66ee03..28afee85 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,16 +1,16 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.1.0 + rev: v3.4.0 hooks: - id: trailing-whitespace - repo: https://github.com/ambv/black - rev: 19.10b0 + rev: 21.6b0 hooks: - id: black - repo: https://github.com/jorisroovers/gitlint - rev: v0.13.1 + rev: v0.15.1 hooks: - id: gitlint diff --git a/lftools/api/endpoints/gerrit.py b/lftools/api/endpoints/gerrit.py index 0100c608..e728d3a8 100644 --- a/lftools/api/endpoints/gerrit.py +++ b/lftools/api/endpoints/gerrit.py @@ -83,7 +83,11 @@ class Gerrit(client.RestApi): access_str = "changes/{}/edit:publish".format(changeid) headers = {"Content-Type": "application/json; charset=UTF-8"} self.r.headers.update(headers) - payload = json.dumps({"notify": "NONE",}) + payload = json.dumps( + { + "notify": "NONE", + } + ) result = self.post(access_str, data=payload) return result ############################################################## @@ -152,7 +156,11 @@ class Gerrit(client.RestApi): access_str = "changes/{}/edit:publish".format(changeid) headers = {"Content-Type": "application/json; charset=UTF-8"} self.r.headers.update(headers) - payload = json.dumps({"notify": "NONE",}) + payload = json.dumps( + { + "notify": "NONE", + } + ) result = self.post(access_str, data=payload) log.info(result) return result @@ -167,7 +175,14 @@ class Gerrit(client.RestApi): headers = {"Content-Type": "application/json; charset=UTF-8"} self.r.headers.update(headers) payload = json.dumps( - {"tag": "automation", "message": "Vote on file", "labels": {"Verified": +1, "Code-Review": +2,}} + { + "tag": "automation", + "message": "Vote on file", + "labels": { + "Verified": +1, + "Code-Review": +2, + }, + } ) result = self.post(access_str, data=payload) @@ -216,7 +231,11 @@ class Gerrit(client.RestApi): else: subject = "Automation adds {0}\n\nSigned-off-by: {1}".format(filename, signed_off_by) payload = json.dumps( - {"project": "{}".format(gerrit_project), "subject": "{}".format(subject), "branch": "master",} + { + "project": "{}".format(gerrit_project), + "subject": "{}".format(subject), + "branch": "master", + } ) return payload @@ -285,7 +304,11 @@ class Gerrit(client.RestApi): access_str = "changes/{}/edit:publish".format(changeid) headers = {"Content-Type": "application/json; charset=UTF-8"} self.r.headers.update(headers) - payload = json.dumps({"notify": "NONE",}) + payload = json.dumps( + { + "notify": "NONE", + } + ) result = self.post(access_str, data=payload) log.info(result) diff --git a/lftools/api/endpoints/nexus2.py b/lftools/api/endpoints/nexus2.py index 02cc6ad6..0011b5c1 100644 --- a/lftools/api/endpoints/nexus2.py +++ b/lftools/api/endpoints/nexus2.py @@ -131,7 +131,11 @@ class Nexus2(client.RestApi): ) if repo_provider == "site": data["data"].update( - {"repoPolicy": "MIXED", "writePolicy": "ALLOW_WRITE", "indexable": False,} + { + "repoPolicy": "MIXED", + "writePolicy": "ALLOW_WRITE", + "indexable": False, + } ) if repo_type == "proxy": diff --git a/lftools/api/endpoints/nexus3.py b/lftools/api/endpoints/nexus3.py index bab2c1e3..ac28582a 100644 --- a/lftools/api/endpoints/nexus3.py +++ b/lftools/api/endpoints/nexus3.py @@ -214,7 +214,12 @@ class Nexus3(client.RestApi): list_of_privileges = [] for privilege in result: list_of_privileges.append( - [privilege["type"], privilege["name"], privilege["description"], privilege["readOnly"],] + [ + privilege["type"], + privilege["name"], + privilege["description"], + privilege["readOnly"], + ] ) return list_of_privileges @@ -277,7 +282,12 @@ class Nexus3(client.RestApi): list_of_tasks = [] for task in result: list_of_tasks.append( - [task["name"], task["message"], task["currentState"], task["lastRunResult"],] + [ + task["name"], + task["message"], + task["currentState"], + task["lastRunResult"], + ] ) return list_of_tasks @@ -365,7 +375,9 @@ class Nexus3(client.RestApi): "repository": repository, } json_data = json.dumps(data) - result = self.get("v1/search/assets?q={}&repository={}".format(query, repository), data=json_data,)[1]["items"] + result = self.get("v1/search/assets?q={}&repository={}".format(query, repository), data=json_data,)[ + 1 + ]["items"] list_of_assets = [] if details: diff --git a/lftools/cli/nexus3/task.py b/lftools/cli/nexus3/task.py index cc292912..72b26703 100644 --- a/lftools/cli/nexus3/task.py +++ b/lftools/cli/nexus3/task.py @@ -35,4 +35,9 @@ def list_tasks(ctx): """List tasks.""" r = ctx.obj["nexus3"] data = r.list_tasks() - log.info(tabulate(data, headers=["Name", "Message", "Current State", "Last Run Result"],)) + log.info( + tabulate( + data, + headers=["Name", "Message", "Current State", "Last Run Result"], + ) + ) diff --git a/lftools/cli/nexus3/user.py b/lftools/cli/nexus3/user.py index fcbee1cd..4c2e2575 100644 --- a/lftools/cli/nexus3/user.py +++ b/lftools/cli/nexus3/user.py @@ -36,7 +36,19 @@ def search_user(ctx, username): """Search users.""" r = ctx.obj["nexus3"] data = r.list_user(username) - log.info(tabulate(data, headers=["User ID", "First Name", "Last Name", "Email Address", "Status", "Roles",],)) + log.info( + tabulate( + data, + headers=[ + "User ID", + "First Name", + "Last Name", + "Email Address", + "Status", + "Roles", + ], + ) + ) @user.command(name="create") diff --git a/lftools/cli/rtd.py b/lftools/cli/rtd.py index 57dc4334..ff2d50c2 100644 --- a/lftools/cli/rtd.py +++ b/lftools/cli/rtd.py @@ -106,7 +106,13 @@ def project_create(ctx, project_name, repository_url, repository_type, homepage, log.info(pformat(data)) -@click.command(name="project-update", context_settings=dict(ignore_unknown_options=True, allow_extra_args=True,)) +@click.command( + name="project-update", + context_settings=dict( + ignore_unknown_options=True, + allow_extra_args=True, + ), +) @click.argument("project-name") @click.pass_context def project_update(ctx, project_name): diff --git a/lftools/nexus/__init__.py b/lftools/nexus/__init__.py index 17a2cd7d..51c8a178 100644 --- a/lftools/nexus/__init__.py +++ b/lftools/nexus/__init__.py @@ -88,7 +88,13 @@ class Nexus: """Create a target with the given patterns.""" url = os.path.join(self.baseurl, "repo_targets") - target = {"data": {"contentClass": "any", "patterns": patterns, "name": name,}} + target = { + "data": { + "contentClass": "any", + "patterns": patterns, + "name": name, + } + } json_data = json.dumps(target).encode(encoding="latin-1") @@ -132,7 +138,9 @@ class Nexus: "data": { "name": name, "description": name, - "method": [priv,], + "method": [ + priv, + ], "repositoryGroupId": "", "repositoryId": "", "repositoryTargetId": target_id, @@ -223,7 +231,10 @@ class Nexus: "email": "{}-deploy@{}".format(name, domain), "firstName": name, "lastName": "Deployment", - "roles": [role_id, "nx-deployment",], + "roles": [ + role_id, + "nx-deployment", + ], "password": password, "status": "active", } diff --git a/tests/test_deploy.py b/tests/test_deploy.py index efcd370b..5b988240 100644 --- a/tests/test_deploy.py +++ b/tests/test_deploy.py @@ -19,7 +19,10 @@ from lftools import cli import lftools.deploy as deploy_sys -FIXTURE_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "fixtures",) +FIXTURE_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "fixtures", +) def test_log_and_exit(): @@ -54,7 +57,9 @@ def test_log_and_exit(): assert excinfo.type == SystemExit -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "deploy"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "deploy"), +) def test_copy_archive_dir(cli_runner, datafiles): """Test copy_archives() command to ensure archives dir is copied.""" os.chdir(str(datafiles)) @@ -68,7 +73,9 @@ def test_copy_archive_dir(cli_runner, datafiles): assert os.path.exists(os.path.join(stage_dir, "test.log")) -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "deploy"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "deploy"), +) def test_copy_archive_pattern(cli_runner, datafiles): """Test copy_archives() command to ensure glob patterns are copied.""" os.chdir(str(datafiles)) @@ -94,7 +101,9 @@ def test_copy_archive_pattern(cli_runner, datafiles): ) -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "deploy"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "deploy"), +) def test_deploy_archive(cli_runner, datafiles, responses): """Test deploy_archives() command for expected upload cases.""" os.chdir(str(datafiles)) @@ -119,7 +128,9 @@ def test_deploy_archive(cli_runner, datafiles, responses): assert result.exit_code == 1 -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "deploy"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "deploy"), +) def test_deploy_archive2(datafiles): """Test deploy_archives() command when archives dir is missing.""" os.chdir(str(datafiles)) @@ -130,7 +141,9 @@ def test_deploy_archive2(datafiles): assert workspace_dir in str(excinfo.value) -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "deploy"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "deploy"), +) def test_deploy_archive3(datafiles): """Test deploy_archives() command when archives dir is a file instead of a dir.""" os.chdir(str(datafiles)) @@ -141,7 +154,9 @@ def test_deploy_archive3(datafiles): assert workspace_dir in str(excinfo.value) -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "deploy"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "deploy"), +) def test_deploy_archive4(cli_runner, datafiles, responses): """Test deploy_archives() command when using duplicated patterns.""" os.chdir(str(datafiles)) @@ -266,7 +281,9 @@ def test_remove_duplicates_and_sort(): assert deploy_sys._remove_duplicates_and_sort(tst[0]) == tst[1] -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "deploy"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "deploy"), +) def test_deploy_logs(cli_runner, datafiles, responses): """Test deploy_logs() command for expected upload cases.""" os.chdir(str(datafiles)) @@ -289,7 +306,9 @@ def test_deploy_logs(cli_runner, datafiles, responses): assert result.exit_code == 0 -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "deploy"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "deploy"), +) def test_deploy_nexus_zip(cli_runner, datafiles, responses): os.chdir(str(datafiles)) nexus_url = "https://nexus.example.org" @@ -298,7 +317,9 @@ def test_deploy_nexus_zip(cli_runner, datafiles, responses): # Test success success_upload_url = "{}/service/local/repositories/{}/content-compressed/{}".format( - nexus_url, nexus_repo, nexus_path, + nexus_url, + nexus_repo, + nexus_path, ) responses.add(responses.POST, success_upload_url, status=201) result = cli_runner.invoke( @@ -336,7 +357,11 @@ def test_deploy_nexus_zip(cli_runner, datafiles, responses): """ - upload_404_url = "{}/service/local/repositories/{}/content-compressed/{}".format(nexus_url, "logs2", nexus_path,) + upload_404_url = "{}/service/local/repositories/{}/content-compressed/{}".format( + nexus_url, + "logs2", + nexus_path, + ) responses.add(responses.POST, upload_404_url, body=upload_404, status=404) result = cli_runner.invoke( cli.cli, @@ -731,7 +756,9 @@ def test__upload_maven_file_to_nexus(responses, mocker): assert "Something went wrong" in str(excinfo.value) -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "deploy"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "deploy"), +) def test_deploy_nexus_snapshot(datafiles, responses): """Test deploy_nexus with snapshot. @@ -762,7 +789,9 @@ def test_deploy_nexus_snapshot(datafiles, responses): deploy_sys.deploy_nexus(nexus_url, deploy_dir, snapshot) -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "deploy"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "deploy"), +) def test_deploy_nexus_nosnapshot(datafiles, responses): """Test deploy_nexus with no snapshot. @@ -786,7 +815,9 @@ def test_deploy_nexus_nosnapshot(datafiles, responses): deploy_sys.deploy_nexus(nexus_url, deploy_dir) -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "deploy"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "deploy"), +) def test_deploy_nexus_stage(datafiles, responses): """Test deploy_nexus_stage.""" url = "http://valid.deploy.stage" diff --git a/tests/test_license.py b/tests/test_license.py index 33037e51..83d9e02b 100644 --- a/tests/test_license.py +++ b/tests/test_license.py @@ -15,10 +15,15 @@ import pytest from lftools import cli -FIXTURE_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "fixtures",) +FIXTURE_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "fixtures", +) -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "license"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "license"), +) def test_check_license(cli_runner, datafiles): """Test check_license() command.""" os.chdir(str(datafiles)) @@ -34,7 +39,9 @@ def test_check_license(cli_runner, datafiles): assert result.exit_code == 1 -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "license"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "license"), +) def test_check_license_directory(cli_runner, datafiles): """Test check_license_directory() command.""" os.chdir(str(datafiles)) diff --git a/tests/test_release_docker_hub.py b/tests/test_release_docker_hub.py index 80c20dc5..0b7bb600 100644 --- a/tests/test_release_docker_hub.py +++ b/tests/test_release_docker_hub.py @@ -19,7 +19,10 @@ import requests from lftools import cli import lftools.nexus.release_docker_hub as rdh -FIXTURE_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "fixtures",) +FIXTURE_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "fixtures", +) def test_remove_http_from_url(): @@ -112,7 +115,9 @@ def test_tag_class_repository_exist(): assert tags.repository_exist == True -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "nexus"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "nexus"), +) class TestTagsRegExpClass: """Test Tags and Regexp for Versions. @@ -487,7 +492,9 @@ class TestProjectClass: assert self.counter.cleanup == 90 -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "nexus"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "nexus"), +) class TestFetchNexus3Catalog: url = "https://nexus3.onap.org:10002/v2/_catalog" diff --git a/tests/test_rtd.py b/tests/test_rtd.py index 91054cae..436ce950 100644 --- a/tests/test_rtd.py +++ b/tests/test_rtd.py @@ -19,10 +19,15 @@ import lftools.api.endpoints.readthedocs as client creds = {"authtype": "token", "endpoint": "https://readthedocs.org/api/v3/", "token": "xyz"} rtd = client.ReadTheDocs(creds=creds) -FIXTURE_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "fixtures",) +FIXTURE_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "fixtures", +) -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "rtd"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "rtd"), +) @responses.activate def test_project_list(datafiles): os.chdir(str(datafiles)) @@ -32,7 +37,9 @@ def test_project_list(datafiles): assert "TestProject1" in rtd.project_list() -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "rtd"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "rtd"), +) @responses.activate def test_project_details(datafiles): os.chdir(str(datafiles)) @@ -44,7 +51,9 @@ def test_project_details(datafiles): assert "slug" in rtd.project_details("TestProject1") -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "rtd"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "rtd"), +) @responses.activate def test_project_version_list(datafiles): os.chdir(str(datafiles)) @@ -60,7 +69,9 @@ def test_project_version_list(datafiles): assert "test-trigger6" in rtd.project_version_list("TestProject1") -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "rtd"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "rtd"), +) @responses.activate def test_project_version_details(datafiles): os.chdir(str(datafiles)) @@ -102,7 +113,9 @@ def test_project_create(): ) -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "rtd"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "rtd"), +) @responses.activate def test_project_build_list(datafiles): os.chdir(str(datafiles)) @@ -118,7 +131,9 @@ def test_project_build_list(datafiles): assert "success" in rtd.project_build_list("testproject1") -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "rtd"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "rtd"), +) @responses.activate def test_project_build_details(datafiles): os.chdir(str(datafiles)) @@ -145,7 +160,9 @@ def test_project_build_trigger(): assert rtd.project_build_trigger("testproject1", "latest") -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "rtd"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "rtd"), +) @responses.activate def test_subproject_list(datafiles): os.chdir(str(datafiles)) @@ -161,7 +178,9 @@ def test_subproject_list(datafiles): assert "testproject2" in rtd.subproject_list("TestProject1") -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "rtd"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "rtd"), +) @responses.activate def test_subproject_details(datafiles): os.chdir(str(datafiles)) diff --git a/tests/test_schema.py b/tests/test_schema.py index e0e07f31..3c2c76c0 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -15,10 +15,15 @@ import pytest from lftools import cli -FIXTURE_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "fixtures",) +FIXTURE_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "fixtures", +) -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "schema"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "schema"), +) def test_check_license(cli_runner, datafiles): """Test check_schema() command.""" os.chdir(str(datafiles)) diff --git a/tests/test_version.py b/tests/test_version.py index dd74daab..9a6e2880 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -17,10 +17,15 @@ import pytest from lftools import cli -FIXTURE_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "fixtures",) +FIXTURE_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "fixtures", +) -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "version_bump"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "version_bump"), +) def test_version_bump(cli_runner, datafiles): """Test version bump command.""" os.chdir(str(datafiles)) @@ -33,7 +38,9 @@ def test_version_bump(cli_runner, datafiles): assert filecmp.cmp(pom, expected_pom) -@pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "version_release"),) +@pytest.mark.datafiles( + os.path.join(FIXTURE_DIR, "version_release"), +) def test_version_release(cli_runner, datafiles): """Test version release command.""" os.chdir(str(datafiles))