Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pre-commit checks to new versions #3501

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/hhatto/autopep8
rev: 'v2.3.1'
rev: 'v2.3.2'
hooks:
- id: autopep8

Expand All @@ -21,7 +21,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.13.0"
rev: "v1.14.1"
hooks:
- id: mypy
language_version: "3.9"
Expand Down Expand Up @@ -69,7 +69,7 @@ repos:
pass_filenames: false

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.390
rev: v1.1.393
hooks:
- id: pyright
language_version: "3.9"
Expand Down Expand Up @@ -115,7 +115,7 @@ repos:
- "types-lxml"

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.30.0"
rev: "0.31.1"
hooks:
- id: check-metaschema
name: "Check JSON schemas validity"
Expand All @@ -128,7 +128,7 @@ repos:
files: ^tmt/(?:schemas|steps/prepare/feature)/.*\.yaml

- repo: https://github.com/ansible-community/ansible-lint.git
rev: v24.10.0
rev: v25.1.1
hooks:
- id: ansible-lint
args:
Expand All @@ -144,15 +144,15 @@ repos:
# in order to be parsed by ansible-lint

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.8.1
rev: v0.9.4
hooks:
- id: ruff
args:
- '--fix'
- '--show-fixes'

- repo: https://github.com/teemtee/tmt.git
rev: 1.39.0
rev: 1.42.0
hooks:
- id: tmt-lint
additional_dependencies:
Expand All @@ -167,14 +167,14 @@ repos:
- "typing-extensions>=4.9.0; python_version < '3.13'"
- "fmf>=1.6.0"
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.1
hooks:
- id: codespell
additional_dependencies:
- tomli # Required for python < 3.11

- repo: https://github.com/djlint/djLint
rev: v1.36.3
rev: v1.36.4
hooks:
- id: djlint
files: "\\.j2"
Expand Down
2 changes: 1 addition & 1 deletion docs/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ as something that will be pasted into release notes:
Why should I care?

* It helps others (and yourself) find relevant commits quickly.
* The summary line will be re-used later (e.g. for rpm changelog).
* The summary line will be reused later (e.g. for rpm changelog).
* Some tools do not handle wrapping, so it is then hard to read.
* You will make the maintainers happy to read beautiful commits :)

Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,13 @@ lint.typing-modules = ["tmt._compat.typing"]
"S108", # Probable insecure usage of temporary file or directory: "{}"
"FLY002", # Use f-string instead of .join
]
# The naming scheme of tmt/_compat will overshadow stdlib modules
"tmt/_compat/pathlib.py" = ["A005"]
"tmt/_compat/typing.py" = ["A005"]
"tmt/_compat/warnings.py" = ["A005"]
# Following files also overshadow stdlib modules
"tmt/queue.py" = ["A005"]
"tmt/steps/report/html.py" = ["A005"]
# The purpose of tmt/_compat is to be used with TID251 (banned imports)
"tmt/_compat/**.py" = ["TID251"]
"docs/conf.py" = ["TID251"]
Expand Down
13 changes: 6 additions & 7 deletions tmt/_pre_commit/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,21 @@ def _run_precommit() -> None: # pyright: ignore[reportUnusedFunction] (used by
assert match
# Actual argument matched
actual_arg = match.group(1)
indx = argv.index(actual_arg)
index = argv.index(actual_arg)
# Example of reorder args:
# ["tmt", "tests", "lint", "--fix", "--root", "/some/path", "some_file"]
# - argv[0]: name of the program is always first
# ["tmt"]
# - argv[indx:indx+1+nargs]: args to move (pass to `tmt.cli._root.main`)
# - argv[index:index+1+nargs]: args to move (pass to `tmt.cli._root.main`)
# ["--root", "/some/path"]
# - argv[1:indx]: all other keywords (`lint` keyword is in here)
# - argv[1:index]: all other keywords (`lint` keyword is in here)
# ["tests", "lint", "--fix"]
# - argv[indx+1+nargs:]: All remaining keywords
# - argv[index+1+nargs:]: All remaining keywords
# ["some_file"]
# After reorder:
# ["tmt", "--root", "/some/path", "tests", "lint", "--fix", "some_file"]
argv = (
argv[0:1] + argv[indx: indx + 1 + nargs] + argv[1:indx] + argv[indx + 1 + nargs:]
)
argv = (argv[0:1] + argv[index: index + 1 + nargs] +
argv[1:index] + argv[index + 1 + nargs:])
# Finally move the reordered args to sys.argv and run the cli
sys.argv = argv
run_cli()
Expand Down
7 changes: 5 additions & 2 deletions tmt/steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2313,7 +2313,10 @@ def phase_name(self) -> str:
# name, which is always the same, would be the name of the discover
# phase it's supposed to process.
if isinstance(self.phase, ExecutePlugin):
return self.phase.discover_phase or self.phase.discover.name
# mypy reports `self.phase` as `Never` type, probably some
# issue in how it's declared above.
return cast(ExecutePlugin[Any], self.phase).discover_phase \
or cast(ExecutePlugin[Any], self.phase).discover.name

return self.phase.name

Expand Down Expand Up @@ -2467,7 +2470,7 @@ def safe_filename(template: str, phase: Phase, guest: 'Guest', **variables: Any)
3. the phase name is included to avoid reuse of the filename by different
phases. A plugin may be invoked by multiple phases, and it might use a
"constant" name for the file. That would lead to the filename being
re-used by different plugin executions. Adding the phase name should
reused by different plugin executions. Adding the phase name should
lower confusion: it would be immediately clear which phase used which
filename, or whether a filename was or was not created by given phase.

Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/finish/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class FinishAnsible(
should happen if there are multiple configs. Default order is '50'.
"""

# We are re-using "prepare" step for "finish",
# We are reusing "prepare" step for "finish",
# and they both have different expectations
_data_class = tmt.steps.prepare.ansible.PrepareAnsibleData

Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/provision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1808,7 +1808,7 @@ def _base_ssh_command(self) -> Command:
def _spawn_ssh_master_process(self) -> subprocess.Popen[bytes]:
""" Spawn the SSH master process """

# NOTE: do not modify `command`, it might be re-used by the caller. To
# NOTE: do not modify `command`, it might be reused by the caller. To
# be safe, include it in our own command.
ssh_master_command = self._base_ssh_command \
+ self._ssh_options \
Expand Down