From b5dce88acb30e9afddccc52cf98b5533792abf13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Prchl=C3=ADk?= Date: Thu, 20 Jun 2024 16:00:20 +0200 Subject: [PATCH] Bump pre-commit checks (#3023) Includes some changes needed to appease new versions of various checks. --- .pre-commit-config.yaml | 16 ++++++++-------- examples/redis/test.sh | 2 +- tests/unit/test_guest.py | 2 +- tmt/queue.py | 2 +- tmt/steps/__init__.py | 6 +++--- tmt/steps/discover/__init__.py | 2 +- tmt/steps/prepare/__init__.py | 4 ++-- tmt/steps/prepare/distgit.py | 4 ++-- tmt/steps/prepare/feature/epel-disable.yaml | 2 +- tmt/steps/prepare/feature/epel-enable.yaml | 16 ++++++++-------- tmt/steps/provision/mrack.py | 8 ++++---- tmt/steps/provision/testcloud.py | 2 +- tmt/utils.py | 4 ++-- 13 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f74d5412be..d28627af6e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/hhatto/autopep8 - rev: 'v2.1.0' + rev: 'v2.3.0' hooks: - id: autopep8 @@ -21,7 +21,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.9.0" + rev: "v1.10.0" hooks: - id: mypy language_version: "3.9" @@ -66,7 +66,7 @@ repos: args: [--config-file=pyproject.toml] - repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.357 + rev: v1.1.367 hooks: - id: pyright language_version: "3.9" @@ -108,7 +108,7 @@ repos: - "types-docutils" - repo: https://github.com/python-jsonschema/check-jsonschema - rev: "0.28.1" + rev: "0.28.5" hooks: - id: check-metaschema name: "Check JSON schemas validity" @@ -121,7 +121,7 @@ repos: files: ^tmt/schemas/.*\.yaml - repo: https://github.com/ansible-community/ansible-lint.git - rev: v24.2.1 + rev: v24.6.0 hooks: - id: ansible-lint args: @@ -137,7 +137,7 @@ repos: # in order to be parsed by ansible-lint - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.3.5 + rev: v0.4.9 hooks: - id: ruff args: @@ -145,7 +145,7 @@ repos: - '--show-fixes' - repo: https://github.com/teemtee/tmt.git - rev: 1.32.1 + rev: 1.33.0 hooks: - id: tmt-lint additional_dependencies: @@ -156,7 +156,7 @@ repos: # There is *a lot* of them, and hatch might fetch many of them. - "botocore>=1.25.10" # 1.25.10 is the current one available for RHEL9 - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + rev: v2.3.0 hooks: - id: codespell additional_dependencies: diff --git a/examples/redis/test.sh b/examples/redis/test.sh index 8f21b3c779..7d538d93fb 100755 --- a/examples/redis/test.sh +++ b/examples/redis/test.sh @@ -3,7 +3,7 @@ set -eux . "$TMT_TOPOLOGY_BASH" -# verify that TOPLOGY to be defined to be able to run the tests. +# verify that TOPOLOGY to be defined to be able to run the tests. test -z "${TMT_ROLES[server]}" && exit 125 SERVER=${TMT_GUESTS[${TMT_ROLES[server]}.hostname]} diff --git a/tests/unit/test_guest.py b/tests/unit/test_guest.py index c6c1a36efa..a075090669 100644 --- a/tests/unit/test_guest.py +++ b/tests/unit/test_guest.py @@ -39,7 +39,7 @@ def test_multihost_name(root_logger: Logger) -> None: ), ( # shared-connection-closed - os.linesep + 'some-line' + os.linesep + 'Shared connection to 127.0.0.1 closed.' \ + os.linesep + 'some-line' + os.linesep + 'Shared connection to 127.0.0.1 closed.' + os.linesep, os.linesep + 'some-line' + os.linesep ) diff --git a/tmt/queue.py b/tmt/queue.py index 2bdcedae09..c0dd4d992c 100644 --- a/tmt/queue.py +++ b/tmt/queue.py @@ -229,7 +229,7 @@ def go(self) -> Iterator['Self']: old_loggers: dict[str, Logger] = {} with ThreadPoolExecutor(max_workers=len(self.guests)) as executor: - futures: dict[Future[None], 'Guest'] = {} + futures: dict[Future[None], Guest] = {} for guest in self.guests: # Swap guest's logger for the one we prepared, with labels diff --git a/tmt/steps/__init__.py b/tmt/steps/__init__.py index c709251669..70ff7c91a8 100644 --- a/tmt/steps/__init__.py +++ b/tmt/steps/__init__.py @@ -369,7 +369,7 @@ def __init__( super().__init__(name=name, parent=plan, workdir=workdir, logger=logger) # Initialize data - self.plan: 'Plan' = plan + self.plan: Plan = plan self._status: Optional[str] = None self._phases: list[Phase] = [] @@ -761,7 +761,7 @@ def _iter_options() -> Iterator[tuple[str, Any]]: # compatible, `--update` without `--name` should result in all phases being converted into # what the `--update` brings in. In this list, we will collect "postponed" CLI invocations, # and we will get back to them once we're done with those we can apply immediately. - postponed_invocations: list['tmt.cli.CliInvocation'] = [] + postponed_invocations: list[tmt.cli.CliInvocation] = [] name_generator = DefaultNameGenerator.from_raw_phases(raw_data) @@ -1937,7 +1937,7 @@ class Topology(SerializableContainer): roles: dict[str, list[str]] def __init__(self, guests: list['Guest']) -> None: - roles: collections.defaultdict[str, list['Guest']] = collections.defaultdict(list) + roles: collections.defaultdict[str, list[Guest]] = collections.defaultdict(list) self.guest = None self.guest_names: list[str] = [] diff --git a/tmt/steps/discover/__init__.py b/tmt/steps/discover/__init__.py index 21f3bcac2d..c70e300b7f 100644 --- a/tmt/steps/discover/__init__.py +++ b/tmt/steps/discover/__init__.py @@ -227,7 +227,7 @@ def save(self) -> None: super().save() # Create tests.yaml with the full test data - raw_test_data: list['tmt.export._RawExportedInstance'] = [] + raw_test_data: list[tmt.export._RawExportedInstance] = [] for phase_name, phase_tests in self._tests.items(): for test in phase_tests: diff --git a/tmt/steps/prepare/__init__.py b/tmt/steps/prepare/__init__.py index c2bd90f03e..ebf7605dc2 100644 --- a/tmt/steps/prepare/__init__.py +++ b/tmt/steps/prepare/__init__.py @@ -277,8 +277,8 @@ def as_key(self) -> frozenset['tmt.base.DependencySimple']: # # 1. make the list of requirements unique, # 2. group guests with same requirements. - pruned_requires: dict[frozenset['tmt.base.DependencySimple'], DependencyCollection] = {} - pruned_recommends: dict[frozenset['tmt.base.DependencySimple'], DependencyCollection] = {} + pruned_requires: dict[frozenset[tmt.base.DependencySimple], DependencyCollection] = {} + pruned_recommends: dict[frozenset[tmt.base.DependencySimple], DependencyCollection] = {} for guest, collection in collected_requires.items(): collection.dependencies = uniq(collection.dependencies) diff --git a/tmt/steps/prepare/distgit.py b/tmt/steps/prepare/distgit.py index a7211952cf..358177f68c 100644 --- a/tmt/steps/prepare/distgit.py +++ b/tmt/steps/prepare/distgit.py @@ -286,8 +286,8 @@ def go( # FIXME needs refactor of Prepare, tmt.base etc... # doing quick & dirty injection of prepareinstalls for guest in self.step.plan.provision.guests(): - collected_requires: list['tmt.base.DependencySimple'] = [] - collected_recommends: list['tmt.base.DependencySimple'] = [] + collected_requires: list[tmt.base.DependencySimple] = [] + collected_recommends: list[tmt.base.DependencySimple] = [] for test in self.step.plan.discover.tests(enabled=True): if not test.enabled_on_guest(guest): continue diff --git a/tmt/steps/prepare/feature/epel-disable.yaml b/tmt/steps/prepare/feature/epel-disable.yaml index 5f5175c9c7..b5c2d4d3d1 100644 --- a/tmt/steps/prepare/feature/epel-disable.yaml +++ b/tmt/steps/prepare/feature/epel-disable.yaml @@ -5,7 +5,7 @@ when: ansible_distribution in ["RedHat", "CentOS"] and ansible_distribution_major_version | int == 7 block: - name: Install package 'yum-utils' - ansible.builtin.yum: + ansible.builtin.dnf: name: yum-utils state: present diff --git a/tmt/steps/prepare/feature/epel-enable.yaml b/tmt/steps/prepare/feature/epel-enable.yaml index adc961af92..481a30640c 100644 --- a/tmt/steps/prepare/feature/epel-enable.yaml +++ b/tmt/steps/prepare/feature/epel-enable.yaml @@ -5,13 +5,13 @@ when: ansible_distribution == "RedHat" and ansible_distribution_major_version | int == 7 block: - name: Install package 'epel-release' - ansible.builtin.yum: + ansible.builtin.dnf: name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm" disable_gpg_check: true state: present - name: Install package 'yum-utils' - ansible.builtin.yum: + ansible.builtin.dnf: name: yum-utils state: present @@ -24,13 +24,13 @@ when: ansible_distribution == "RedHat" and ansible_distribution_major_version | int >= 8 block: - name: Install package 'epel-release' - ansible.builtin.yum: + ansible.builtin.dnf: name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm" disable_gpg_check: true state: present - name: Install package 'epel-next-release' - ansible.builtin.yum: + ansible.builtin.dnf: name: "https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm" disable_gpg_check: true state: present @@ -54,12 +54,12 @@ when: ansible_distribution == "CentOS" and ansible_distribution_major_version | int == 7 block: - name: Install package 'epel-release' - ansible.builtin.yum: + ansible.builtin.dnf: name: epel-release state: present - name: Install package 'yum-utils' - ansible.builtin.yum: + ansible.builtin.dnf: name: yum-utils state: present @@ -72,12 +72,12 @@ when: ansible_distribution == "CentOS" and ansible_distribution_major_version | int >= 8 block: - name: Install package 'epel-release' - ansible.builtin.yum: + ansible.builtin.dnf: name: epel-release state: present - name: Install package 'epel-next-release' - ansible.builtin.yum: + ansible.builtin.dnf: name: epel-next-release state: present diff --git a/tmt/steps/provision/mrack.py b/tmt/steps/provision/mrack.py index 1559777c36..e11843f8d0 100644 --- a/tmt/steps/provision/mrack.py +++ b/tmt/steps/provision/mrack.py @@ -447,10 +447,10 @@ def _transform_zcrypt_mode( 'disk.size': _transform_disk_size, # type: ignore[dict-item] 'hostname': _transform_hostname, # type: ignore[dict-item] 'memory': _transform_memory, # type: ignore[dict-item] - 'virtualization.is_virtualized': \ - _transform_virtualization_is_virtualized, # type: ignore[dict-item] - 'virtualization.hypervisor': \ - _transform_virtualization_hypervisor, # type: ignore[dict-item] + 'virtualization.is_virtualized': + _transform_virtualization_is_virtualized, # type: ignore[dict-item] + 'virtualization.hypervisor': + _transform_virtualization_hypervisor, # type: ignore[dict-item] 'zcrypt.adapter': _transform_zcrypt_adapter, # type: ignore[dict-item] 'zcrypt.mode': _transform_zcrypt_mode, # type: ignore[dict-item] } diff --git a/tmt/steps/provision/testcloud.py b/tmt/steps/provision/testcloud.py index 9681c649bf..c0d896f253 100644 --- a/tmt/steps/provision/testcloud.py +++ b/tmt/steps/provision/testcloud.py @@ -440,7 +440,7 @@ def _apply_hw_disk_size( logger: tmt.log.Logger) -> None: """ Apply ``disk`` constraint to given VM domain """ - final_size: 'Size' = DEFAULT_DISK + final_size: Size = DEFAULT_DISK def _generate_disk_filepaths() -> Iterator[Path]: """ Generate paths to use for files representing VM storage """ diff --git a/tmt/utils.py b/tmt/utils.py index f806d5e77e..04b1f1b941 100644 --- a/tmt/utils.py +++ b/tmt/utils.py @@ -1469,7 +1469,7 @@ def __init__(cls, *args: Any, **kwargs: Any) -> None: # of the assignment below. That's incomplete, and leads to mypy warning # about assignments of `CliInvocation` instances to this attribute. # Repeating the annotation silences mypy, giving it better picture. - cls.cli_invocation: Optional['tmt.cli.CliInvocation'] = None + cls.cli_invocation: Optional[tmt.cli.CliInvocation] = None class Common(_CommonBase, metaclass=_CommonMeta): @@ -2197,7 +2197,7 @@ class _MultiInvokableCommonMeta(_CommonMeta): def __init__(cls, *args: Any, **kwargs: Any) -> None: # noqa: N805 super().__init__(*args, **kwargs) - cls.cli_invocations: list['tmt.cli.CliInvocation'] = [] + cls.cli_invocations: list[tmt.cli.CliInvocation] = [] class MultiInvokableCommon(Common, metaclass=_MultiInvokableCommonMeta):