Skip to content

Commit e05b21a

Browse files
authored
Bump pre-commit checks (#3531)
New mypy lets us drop a lot of `ignore` waivers in CLI code \o/
1 parent e994780 commit e05b21a

File tree

5 files changed

+55
-82
lines changed

5 files changed

+55
-82
lines changed

.pre-commit-config.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
- id: trailing-whitespace
1717

1818
- repo: https://github.com/pre-commit/mirrors-mypy
19-
rev: "v1.14.1"
19+
rev: "v1.15.0"
2020
hooks:
2121
- id: mypy
2222
language_version: "3.9"
@@ -64,7 +64,7 @@ repos:
6464
pass_filenames: false
6565

6666
- repo: https://github.com/RobertCraigie/pyright-python
67-
rev: v1.1.393
67+
rev: v1.1.395
6868
hooks:
6969
- id: pyright
7070
language_version: "3.9"
@@ -110,7 +110,7 @@ repos:
110110
- "types-lxml"
111111

112112
- repo: https://github.com/python-jsonschema/check-jsonschema
113-
rev: "0.31.1"
113+
rev: "0.31.2"
114114
hooks:
115115
- id: check-metaschema
116116
name: "Check JSON schemas validity"
@@ -123,7 +123,7 @@ repos:
123123
files: ^tmt/(?:schemas|steps/prepare/feature)/.*\.yaml
124124

125125
- repo: https://github.com/ansible-community/ansible-lint.git
126-
rev: v25.1.1
126+
rev: v25.1.3
127127
hooks:
128128
- id: ansible-lint
129129
args:
@@ -139,7 +139,7 @@ repos:
139139
# in order to be parsed by ansible-lint
140140

141141
- repo: https://github.com/charliermarsh/ruff-pre-commit
142-
rev: v0.9.4
142+
rev: v0.9.8
143143
hooks:
144144
- id: ruff
145145
args:
@@ -148,7 +148,7 @@ repos:
148148
- id: ruff-format
149149

150150
- repo: https://github.com/teemtee/tmt.git
151-
rev: 1.42.1
151+
rev: 1.43.0
152152
hooks:
153153
- id: tmt-lint
154154
additional_dependencies:
@@ -189,7 +189,7 @@ repos:
189189
- "--"
190190

191191
- repo: https://github.com/hadolint/hadolint
192-
rev: v2.12.0
192+
rev: v2.13.1-beta
193193
hooks:
194194
# * hadolint-docker depends hard on Docker, ignores podman
195195
# * pre-commit check does not install hadolint binary,

tmt/cli/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import enum
77
import functools
88
from collections.abc import Sequence
9-
from typing import TYPE_CHECKING, Any, Callable, Optional, TypeVar
9+
from typing import TYPE_CHECKING, Any, Callable, Optional, TypeVar, cast
1010

1111
import click
1212
import fmf
@@ -100,7 +100,10 @@ class ContextObject:
100100
clean: Optional[tmt.Clean] = None
101101
clean_logger: Optional[tmt.log.Logger] = None
102102
clean_partials: collections.defaultdict[str, list[tmt.base.CleanCallback]] = simple_field(
103-
default_factory=lambda: collections.defaultdict(list)
103+
default_factory=lambda: cast(
104+
collections.defaultdict[str, list[tmt.base.CleanCallback]],
105+
collections.defaultdict(list),
106+
)
104107
)
105108
run: Optional[tmt.Run] = None
106109

tmt/cli/_root.py

+32-58
Original file line numberDiff line numberDiff line change
@@ -425,12 +425,11 @@ def run_tests(context: Context, **kwargs: Any) -> None:
425425

426426

427427
# TODO: commands is unknown, needs revisit
428-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
429-
# inference. See Context and ContextObjects above.
430-
@run.result_callback() # type: ignore[arg-type]
428+
@run.result_callback()
431429
@pass_context
432430
def finito(
433431
click_context: Context,
432+
/,
434433
commands: Any,
435434
*args: Any,
436435
**kwargs: Any,
@@ -448,12 +447,10 @@ def finito(
448447
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
449448

450449

451-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
452-
# inference. See Context and ContextObjects above.
453-
@main.group(invoke_without_command=True, cls=CustomGroup) # type: ignore[arg-type]
450+
@main.group(invoke_without_command=True, cls=CustomGroup)
454451
@pass_context
455452
@verbosity_options
456-
def tests(context: Context, **kwargs: Any) -> None:
453+
def tests(context: Context, /, **kwargs: Any) -> None:
457454
"""
458455
Manage tests (L1 metadata).
459456
@@ -468,13 +465,11 @@ def tests(context: Context, **kwargs: Any) -> None:
468465
tmt.Test.overview(context.obj.tree)
469466

470467

471-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
472-
# inference. See Context and ContextObjects above.
473-
@tests.command(name='ls') # type: ignore[arg-type]
468+
@tests.command(name='ls')
474469
@pass_context
475470
@filtering_options
476471
@verbosity_options
477-
def tests_ls(context: Context, **kwargs: Any) -> None:
472+
def tests_ls(context: Context, /, **kwargs: Any) -> None:
478473
"""
479474
List available tests.
480475
@@ -487,13 +482,11 @@ def tests_ls(context: Context, **kwargs: Any) -> None:
487482
test.ls()
488483

489484

490-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
491-
# inference. See Context and ContextObjects above.
492-
@tests.command(name='show') # type: ignore[arg-type]
485+
@tests.command(name='show')
493486
@pass_context
494487
@filtering_options
495488
@verbosity_options
496-
def tests_show(context: Context, **kwargs: Any) -> None:
489+
def tests_show(context: Context, /, **kwargs: Any) -> None:
497490
"""
498491
Show test details.
499492
@@ -949,14 +942,12 @@ def tests_export(
949942
)
950943

951944

952-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
953-
# inference. See Context and ContextObjects above.
954-
@tests.command(name="id") # type: ignore[arg-type]
945+
@tests.command(name="id")
955946
@pass_context
956947
@filtering_options
957948
@verbosity_options
958949
@force_dry_options
959-
def tests_id(context: Context, **kwargs: Any) -> None:
950+
def tests_id(context: Context, /, **kwargs: Any) -> None:
960951
"""
961952
Generate a unique id for each selected test.
962953
@@ -975,13 +966,11 @@ def tests_id(context: Context, **kwargs: Any) -> None:
975966
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
976967

977968

978-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
979-
# inference. See Context and ContextObjects above.
980-
@main.group(invoke_without_command=True, cls=CustomGroup) # type: ignore[arg-type]
969+
@main.group(invoke_without_command=True, cls=CustomGroup)
981970
@pass_context
982971
@verbosity_options
983972
@remote_plan_options
984-
def plans(context: Context, **kwargs: Any) -> None:
973+
def plans(context: Context, /, **kwargs: Any) -> None:
985974
"""
986975
Manage test plans (L2 metadata).
987976
@@ -997,14 +986,12 @@ def plans(context: Context, **kwargs: Any) -> None:
997986
tmt.Plan.overview(context.obj.tree)
998987

999988

1000-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
1001-
# inference. See Context and ContextObjects above.
1002-
@plans.command(name='ls') # type: ignore[arg-type]
989+
@plans.command(name='ls')
1003990
@pass_context
1004991
@filtering_options
1005992
@verbosity_options
1006993
@remote_plan_options
1007-
def plans_ls(context: Context, **kwargs: Any) -> None:
994+
def plans_ls(context: Context, /, **kwargs: Any) -> None:
1008995
"""
1009996
List available plans.
1010997
@@ -1017,15 +1004,13 @@ def plans_ls(context: Context, **kwargs: Any) -> None:
10171004
plan.ls()
10181005

10191006

1020-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
1021-
# inference. See Context and ContextObjects above.
1022-
@plans.command(name='show') # type: ignore[arg-type]
1007+
@plans.command(name='show')
10231008
@pass_context
10241009
@filtering_options
10251010
@environment_options
10261011
@verbosity_options
10271012
@remote_plan_options
1028-
def plans_show(context: Context, **kwargs: Any) -> None:
1013+
def plans_show(context: Context, /, **kwargs: Any) -> None:
10291014
"""
10301015
Show plan details.
10311016
@@ -1187,14 +1172,12 @@ def plans_export(
11871172
)
11881173

11891174

1190-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
1191-
# inference. See Context and ContextObjects above.
1192-
@plans.command(name="id") # type: ignore[arg-type]
1175+
@plans.command(name="id")
11931176
@pass_context
11941177
@filtering_options
11951178
@verbosity_options
11961179
@force_dry_options
1197-
def plans_id(context: Context, **kwargs: Any) -> None:
1180+
def plans_id(context: Context, /, **kwargs: Any) -> None:
11981181
"""
11991182
Generate a unique id for each selected plan.
12001183
@@ -1213,12 +1196,10 @@ def plans_id(context: Context, **kwargs: Any) -> None:
12131196
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12141197

12151198

1216-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
1217-
# inference. See Context and ContextObjects above.
1218-
@main.group(invoke_without_command=True, cls=CustomGroup) # type: ignore[arg-type]
1199+
@main.group(invoke_without_command=True, cls=CustomGroup)
12191200
@pass_context
12201201
@verbosity_options
1221-
def stories(context: Context, **kwargs: Any) -> None:
1202+
def stories(context: Context, /, **kwargs: Any) -> None:
12221203
"""
12231204
Manage user stories.
12241205
@@ -1234,15 +1215,14 @@ def stories(context: Context, **kwargs: Any) -> None:
12341215
tmt.Story.overview(context.obj.tree)
12351216

12361217

1237-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
1238-
# inference. See Context and ContextObjects above.
1239-
@stories.command(name='ls') # type: ignore[arg-type]
1218+
@stories.command(name='ls')
12401219
@pass_context
12411220
@filtering_options_long
12421221
@story_flags_filter_options
12431222
@verbosity_options
12441223
def stories_ls(
12451224
context: Context,
1225+
/,
12461226
implemented: bool,
12471227
verified: bool,
12481228
documented: bool,
@@ -1275,15 +1255,14 @@ def stories_ls(
12751255
story.ls()
12761256

12771257

1278-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
1279-
# inference. See Context and ContextObjects above.
1280-
@stories.command(name='show') # type: ignore[arg-type]
1258+
@stories.command(name='show')
12811259
@pass_context
12821260
@filtering_options_long
12831261
@story_flags_filter_options
12841262
@verbosity_options
12851263
def stories_show(
12861264
context: Context,
1265+
/,
12871266
implemented: bool,
12881267
verified: bool,
12891268
documented: bool,
@@ -1363,9 +1342,7 @@ def stories_create(
13631342
)
13641343

13651344

1366-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
1367-
# inference. See Context and ContextObjects above.
1368-
@stories.command(name='coverage') # type: ignore[arg-type]
1345+
@stories.command(name='coverage')
13691346
@option('--docs', is_flag=True, help='Show docs coverage.')
13701347
@option('--test', is_flag=True, help='Show test coverage.')
13711348
@option('--code', is_flag=True, help='Show code coverage.')
@@ -1375,6 +1352,7 @@ def stories_create(
13751352
@verbosity_options
13761353
def stories_coverage(
13771354
context: Context,
1355+
/,
13781356
code: bool,
13791357
test: bool,
13801358
docs: bool,
@@ -1541,16 +1519,15 @@ def stories_export(
15411519
)
15421520

15431521

1544-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
1545-
# inference. See Context and ContextObjects above.
1546-
@stories.command(name="id") # type: ignore[arg-type]
1522+
@stories.command(name="id")
15471523
@pass_context
15481524
@filtering_options_long
15491525
@story_flags_filter_options
15501526
@verbosity_options
15511527
@force_dry_options
15521528
def stories_id(
15531529
context: Context,
1530+
/,
15541531
implemented: bool,
15551532
verified: bool,
15561533
documented: bool,
@@ -1688,12 +1665,11 @@ def clean(
16881665
raise SystemExit(exit_code)
16891666

16901667

1691-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
1692-
# inference. See Context and ContextObjects above.
1693-
@clean.result_callback() # type: ignore[arg-type]
1668+
@clean.result_callback()
16941669
@pass_context
16951670
def perform_clean(
16961671
click_context: Context,
1672+
/,
16971673
commands: Any,
16981674
*args: Any,
16991675
**kwargs: Any,
@@ -1848,14 +1824,12 @@ def clean_guests(
18481824
)
18491825

18501826

1851-
# ignore[arg-type]: click code expects click.Context, but we use our own type for better type
1852-
# inference. See Context and ContextObjects above.
1853-
@clean.command(name='images') # type: ignore[arg-type]
1827+
@clean.command(name='images')
18541828
@pass_context
18551829
@workdir_root_options
18561830
@verbosity_options
18571831
@dry_options
1858-
def clean_images(context: Context, workdir_root: Optional[Path], **kwargs: Any) -> None:
1832+
def clean_images(context: Context, /, workdir_root: Optional[Path], **kwargs: Any) -> None:
18591833
"""
18601834
Remove images of supported provision methods.
18611835

0 commit comments

Comments
 (0)