1
1
from __future__ import annotations
2
2
3
+ from pathlib import Path
4
+
3
5
import pytest
4
6
import ruamel .yaml
5
7
13
15
("foo=bar,baz" , ("foo" , {"bar" , "baz" })),
14
16
],
15
17
)
16
- def test_format_bind (value , expected ) :
18
+ def test_format_bind (value : str , expected : tuple [ str , set [ str ]]) -> None :
17
19
assert sync_hooks_additional_dependencies .format_bind (value = value ) == expected
18
20
19
21
20
- def test_format_bind__error ():
22
+ def test_format_bind__error () -> None :
21
23
with pytest .raises (ValueError ):
22
24
sync_hooks_additional_dependencies .format_bind (value = "foo" )
23
25
24
26
25
- def test_combine_bind_values ():
27
+ def test_combine_bind_values () -> None :
26
28
bind = [("foo" , {"bar" }), ("foo" , {"baz" }), ("qux" , {"quux" })]
27
29
assert sync_hooks_additional_dependencies .combine_bind_values (bind = bind ) == {
28
30
"foo" : {"bar" , "baz" },
29
31
"qux" : {"quux" },
30
32
}
31
33
32
34
33
- def test_get_sync_hooks_additional_dependencies_parser ():
34
- parser = sync_hooks_additional_dependencies .get_sync_hooks_additional_dependencies_parser ()
35
+ def test_get_sync_hooks_additional_dependencies_parser () -> None :
36
+ parser = (
37
+ sync_hooks_additional_dependencies .get_sync_hooks_additional_dependencies_parser ()
38
+ )
35
39
assert parser .parse_args (["--bind" , "foo=bar,baz" , "--bind" , "foo=qux" ]).bind == [
36
40
("foo" , {"bar" , "baz" }),
37
41
("foo" , {"qux" }),
38
42
]
39
43
40
44
41
- def test_get_poetry_deps (poetry_cwd ) :
45
+ def test_get_poetry_deps (poetry_cwd : Path ) -> None :
42
46
results = list (
43
47
sync_hooks_additional_dependencies .get_poetry_deps (
44
48
cwd = poetry_cwd ,
@@ -53,7 +57,7 @@ def test_get_poetry_deps(poetry_cwd):
53
57
]
54
58
55
59
56
- def test_get_poetry_deps__error (poetry_cwd ) :
60
+ def test_get_poetry_deps__error (poetry_cwd : Path ) -> None :
57
61
with pytest .raises (SystemError ):
58
62
list (
59
63
sync_hooks_additional_dependencies .get_poetry_deps (
@@ -63,11 +67,11 @@ def test_get_poetry_deps__error(poetry_cwd):
63
67
)
64
68
65
69
66
- def test__sync_hooks_additional_dependencies ():
70
+ def test__sync_hooks_additional_dependencies () -> None :
67
71
config = {"repos" : [{"hooks" : [{"id" : "mypy" }, {"id" : "foo" }]}]}
68
72
deps_by_group = {
69
- "types" : [ "bar==1" , "baz[e]==2" ] ,
70
- "main" : [ "qux==3" ] ,
73
+ "types" : { "bar==1" , "baz[e]==2" } ,
74
+ "main" : { "qux==3" } ,
71
75
}
72
76
bind = {"mypy" : {"types" , "main" , "unknown" }, "other_unknown" : {"abc" }}
73
77
sync_hooks_additional_dependencies ._sync_hooks_additional_dependencies (
@@ -94,7 +98,7 @@ def test__sync_hooks_additional_dependencies():
94
98
}
95
99
96
100
97
- def test_sync_hooks_additional_dependencies (tmp_path , poetry_cwd ) :
101
+ def test_sync_hooks_additional_dependencies (tmp_path : Path , poetry_cwd : Path ) -> None :
98
102
pre_commit_path = tmp_path / ".pre-commit-config.yaml"
99
103
ruamel .yaml .YAML ().dump (
100
104
{
0 commit comments