Chore: Upgrade pre-commit hooks 60/68160/2
authorAndrew Grimberg <agrimberg@linuxfoundation.org>
Mon, 28 Jun 2021 17:28:24 +0000 (10:28 -0700)
committerAndrew Grimberg <agrimberg@linuxfoundation.org>
Tue, 29 Jun 2021 17:37:49 +0000 (10:37 -0700)
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 <agrimberg@linuxfoundation.org>
14 files changed:
.pre-commit-config.yaml
lftools/api/endpoints/gerrit.py
lftools/api/endpoints/nexus2.py
lftools/api/endpoints/nexus3.py
lftools/cli/nexus3/task.py
lftools/cli/nexus3/user.py
lftools/cli/rtd.py
lftools/nexus/__init__.py
tests/test_deploy.py
tests/test_license.py
tests/test_release_docker_hub.py
tests/test_rtd.py
tests/test_schema.py
tests/test_version.py

index 0b66ee0..28afee8 100644 (file)
@@ -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
index 0100c60..e728d3a 100644 (file)
@@ -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)
 
index 02cc6ad..0011b5c 100644 (file)
@@ -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":
index bab2c1e..ac28582 100644 (file)
@@ -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:
index cc29291..72b2670 100644 (file)
@@ -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"],
+        )
+    )
index fcbee1c..4c2e257 100644 (file)
@@ -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")
index 57dc433..ff2d50c 100644 (file)
@@ -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):
index 17a2cd7..51c8a17 100644 (file)
@@ -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",
             }
index efcd370..5b98824 100644 (file)
@@ -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):
   </body>
 </html>
 """
-    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"
index 33037e5..83d9e02 100644 (file)
@@ -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))
index 80c20dc..0b7bb60 100644 (file)
@@ -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"
index 91054ca..436ce95 100644 (file)
@@ -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))
index e0e07f3..3c2c76c 100644 (file)
@@ -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))
index dd74daa..9a6e288 100644 (file)
@@ -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))