@@ -25,7 +25,7 @@ def test_main_noop(tmpdir):
2525 assert cfg .read () == s
2626
2727
28- def test_main_writes_both (tmpdir ):
28+ def test_main_writes_all (tmpdir ):
2929 cfg = tmpdir .join ('.pre-commit-config.yaml' )
3030 cfg .write (
3131 'repos:\n '
@@ -44,7 +44,12 @@ def test_main_writes_both(tmpdir):
4444 ' rev: 6.0.0\n '
4545 ' hooks:\n '
4646 ' - id: flake8\n '
47- # all 3 below should be rewritten
47+ # gives the `mypy` version
48+ '- repo: https://github.com/pre-commit/mirrors-mypy\n '
49+ ' rev: v1.13.0\n '
50+ ' hooks:\n '
51+ ' - id: mypy\n '
52+ # all repos below should have their additional_dependencies rewritten
4853 '- repo: https://github.com/asottile/yesqa\n '
4954 ' rev: v1.5.0\n '
5055 ' hooks:\n '
@@ -57,13 +62,20 @@ def test_main_writes_both(tmpdir):
5762 ' - id: blacken-docs\n '
5863 ' additional_dependencies:\n '
5964 ' - black==22.12.0\n '
65+ '- repo: https://github.com/nbQA-dev/nbQA\n '
66+ ' rev: 1.9.1\n '
67+ ' hooks:\n '
68+ ' - id: nbqa-mypy\n '
69+ ' additional_dependencies:\n '
70+ ' - mypy==0.910\n '
6071 '- repo: https://github.com/example/example\n '
6172 ' rev: v1.0.0\n '
6273 ' hooks:\n '
6374 ' - id: example\n '
6475 ' additional_dependencies:\n '
6576 ' - black==22.12.0\n '
66- ' - flake8==5.0.0\n ' ,
77+ ' - flake8==5.0.0\n '
78+ ' - mypy==0.123\n ' ,
6779 )
6880
6981 assert main ((str (cfg ),))
@@ -82,6 +94,10 @@ def test_main_writes_both(tmpdir):
8294 ' rev: 6.0.0\n '
8395 ' hooks:\n '
8496 ' - id: flake8\n '
97+ '- repo: https://github.com/pre-commit/mirrors-mypy\n '
98+ ' rev: v1.13.0\n '
99+ ' hooks:\n '
100+ ' - id: mypy\n '
85101 '- repo: https://github.com/asottile/yesqa\n '
86102 ' rev: v1.5.0\n '
87103 ' hooks:\n '
@@ -94,13 +110,20 @@ def test_main_writes_both(tmpdir):
94110 ' - id: blacken-docs\n '
95111 ' additional_dependencies:\n '
96112 ' - black==23.3.0\n '
113+ '- repo: https://github.com/nbQA-dev/nbQA\n '
114+ ' rev: 1.9.1\n '
115+ ' hooks:\n '
116+ ' - id: nbqa-mypy\n '
117+ ' additional_dependencies:\n '
118+ ' - mypy==1.13.0\n '
97119 '- repo: https://github.com/example/example\n '
98120 ' rev: v1.0.0\n '
99121 ' hooks:\n '
100122 ' - id: example\n '
101123 ' additional_dependencies:\n '
102124 ' - black==23.3.0\n '
103125 ' - flake8==6.0.0\n '
126+ ' - mypy==1.13.0\n '
104127 )
105128
106129
@@ -117,15 +140,23 @@ def test_main_no_dep_on_one_and_writes_other(tmpdir):
117140 ' hooks:\n '
118141 ' - id: yesqa\n '
119142 ' additional_dependencies:\n '
120- # should not be rewritten because target version can't be found
143+ # should not be rewritten because target versions can't be found
121144 ' - flake8==5.0.0\n '
145+ ' - mypy==0.910\n '
122146 '- repo: https://github.com/adamchainz/blacken-docs\n '
123147 ' rev: 1.15.0\n '
124148 ' hooks:\n '
125149 ' - id: blacken-docs\n '
126150 ' additional_dependencies:\n '
127151 # should be rewritten
128- ' - black==22.12.0\n ' ,
152+ ' - black==22.12.0\n '
153+ '- repo: https://github.com/nbQA-dev/nbQA\n '
154+ ' rev: 1.9.1\n '
155+ ' hooks:\n '
156+ ' - id: nbqa-mypy\n '
157+ ' additional_dependencies:\n '
158+ # should not be rewritten because target version can't be found
159+ ' - mypy==0.123' ,
129160 )
130161
131162 assert main ((str (cfg ),))
@@ -142,10 +173,17 @@ def test_main_no_dep_on_one_and_writes_other(tmpdir):
142173 ' - id: yesqa\n '
143174 ' additional_dependencies:\n '
144175 ' - flake8==5.0.0\n '
176+ ' - mypy==0.910\n '
145177 '- repo: https://github.com/adamchainz/blacken-docs\n '
146178 ' rev: 1.15.0\n '
147179 ' hooks:\n '
148180 ' - id: blacken-docs\n '
149181 ' additional_dependencies:\n '
150182 ' - black==23.3.0\n '
183+ '- repo: https://github.com/nbQA-dev/nbQA\n '
184+ ' rev: 1.9.1\n '
185+ ' hooks:\n '
186+ ' - id: nbqa-mypy\n '
187+ ' additional_dependencies:\n '
188+ ' - mypy==0.123\n '
151189 )
0 commit comments