From dfff49e31fbcf2d26aaf9aa773a0c98c52a16715 Mon Sep 17 00:00:00 2001 From: Jonas L Date: Tue, 27 Jun 2023 11:50:13 +0200 Subject: [PATCH] chore: setup pre-commit (#234) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: add pre-commit config * chore: fix pre-commit errors * chore: add black pre-commit hook * style: format python files with black * chore: add isort pre-commit hook * style: format python files using isort * chore: add pyupgrade pre-commit hook * refactor: upgrade code to python3.7 * Allow stacking PRs Co-authored-by: Julian Tölle --------- Co-authored-by: Julian Tölle --- .azure-pipelines/scripts/combine-coverage.py | 26 +- .azure-pipelines/scripts/time-command.py | 10 +- .github/workflows/lint.yml | 23 ++ .gitlab-ci.yml | 11 + .pre-commit-config.yaml | 43 ++++ plugins/doc_fragments/hcloud.py | 10 +- plugins/inventory/hcloud.py | 70 ++--- plugins/module_utils/hcloud.py | 6 +- plugins/modules/hcloud_certificate.py | 44 +--- plugins/modules/hcloud_certificate_info.py | 47 ++-- plugins/modules/hcloud_datacenter_info.py | 52 ++-- plugins/modules/hcloud_firewall.py | 41 ++- plugins/modules/hcloud_floating_ip.py | 42 +-- plugins/modules/hcloud_floating_ip_info.py | 61 +++-- plugins/modules/hcloud_image_info.py | 74 +++--- plugins/modules/hcloud_load_balancer.py | 45 ++-- plugins/modules/hcloud_load_balancer_info.py | 67 +++-- .../modules/hcloud_load_balancer_network.py | 19 +- .../modules/hcloud_load_balancer_service.py | 138 ++++------ .../modules/hcloud_load_balancer_target.py | 86 +++---- .../modules/hcloud_load_balancer_type_info.py | 48 ++-- plugins/modules/hcloud_location_info.py | 54 ++-- plugins/modules/hcloud_network.py | 30 +-- plugins/modules/hcloud_network_info.py | 54 ++-- plugins/modules/hcloud_placement_group.py | 28 +- plugins/modules/hcloud_primary_ip.py | 28 +- plugins/modules/hcloud_primary_ip_info.py | 49 ++-- plugins/modules/hcloud_rdns.py | 40 +-- plugins/modules/hcloud_route.py | 13 +- plugins/modules/hcloud_server.py | 239 ++++++++---------- plugins/modules/hcloud_server_info.py | 81 +++--- plugins/modules/hcloud_server_network.py | 14 +- plugins/modules/hcloud_server_type_info.py | 74 +++--- plugins/modules/hcloud_ssh_key.py | 36 +-- plugins/modules/hcloud_ssh_key_info.py | 61 ++--- plugins/modules/hcloud_subnetwork.py | 28 +- plugins/modules/hcloud_volume.py | 38 +-- plugins/modules/hcloud_volume_info.py | 61 ++--- pyproject.toml | 6 + .../hcloud_server_type_info/defaults/main.yml | 2 +- tests/utils/shippable/check_matrix.py | 87 ++++--- tests/utils/shippable/timing.py | 9 +- 42 files changed, 904 insertions(+), 1091 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .pre-commit-config.yaml create mode 100644 pyproject.toml diff --git a/.azure-pipelines/scripts/combine-coverage.py b/.azure-pipelines/scripts/combine-coverage.py index 506ade6..afadeaa 100755 --- a/.azure-pipelines/scripts/combine-coverage.py +++ b/.azure-pipelines/scripts/combine-coverage.py @@ -7,8 +7,6 @@ Keep in mind that Azure Pipelines does not enforce unique job display names (onl It is up to pipeline authors to avoid name collisions when deviating from the recommended format. """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type import os import re @@ -20,12 +18,12 @@ def main(): """Main program entry point.""" source_directory = sys.argv[1] - if '/ansible_collections/' in os.getcwd(): + if "/ansible_collections/" in os.getcwd(): output_path = "tests/output" else: output_path = "test/results" - destination_directory = os.path.join(output_path, 'coverage') + destination_directory = os.path.join(output_path, "coverage") if not os.path.exists(destination_directory): os.makedirs(destination_directory) @@ -34,27 +32,27 @@ def main(): count = 0 for name in os.listdir(source_directory): - match = re.search('^Coverage (?P[0-9]+) (?P