File tree Expand file tree Collapse file tree 2 files changed +42
-20
lines changed
Expand file tree Collapse file tree 2 files changed +42
-20
lines changed Original file line number Diff line number Diff line change @@ -53,12 +53,13 @@ def main(argv: Sequence[str] | None = None) -> int:
5353 # TODO - validate schema?
5454 versions = {}
5555 for repo in loaded ['repos' ]:
56- for hook in repo ['hooks' ]:
57- if (hid := hook ['id' ]) in SUPPORTED :
58- # `mirrors-mypy` uses versions with a 'v' prefix, so we have to
59- # strip it out to get the mypy version.
60- cleaned_rev = repo ['rev' ].removeprefix ('v' )
61- versions [hid ] = cleaned_rev
56+ if repo ['repo' ] not in ('local' , 'meta' ):
57+ for hook in repo ['hooks' ]:
58+ if (hid := hook ['id' ]) in SUPPORTED :
59+ # `mirrors-mypy` uses versions with a 'v' prefix, so we
60+ # have to strip it out to get the mypy version.
61+ cleaned_rev = repo ['rev' ].removeprefix ('v' )
62+ versions [hid ] = cleaned_rev
6263
6364 updated = []
6465 for repo in loaded ['repos' ]:
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import pytest
4+
35from sync_pre_commit_deps import main
46
57
6- def test_main_noop (tmpdir ):
7- s = (
8- 'repos:\n '
9- '- repo: https://github.com/psf/black\n '
10- ' rev: 23.3.0\n '
11- ' hooks:\n '
12- ' - id: black\n '
13- '- repo: https://github.com/adamchainz/blacken-docs\n '
14- ' rev: 1.15.0\n '
15- ' hooks:\n '
16- ' - id: blacken-docs\n '
17- ' additional_dependencies:\n '
18- ' - black==23.3.0\n '
19- )
8+ @pytest .mark .parametrize (
9+ ('s' ,),
10+ (
11+ pytest .param (
12+ 'repos:\n '
13+ '- repo: https://github.com/psf/black\n '
14+ ' rev: 23.3.0\n '
15+ ' hooks:\n '
16+ ' - id: black\n '
17+ '- repo: https://github.com/adamchainz/blacken-docs\n '
18+ ' rev: 1.15.0\n '
19+ ' hooks:\n '
20+ ' - id: blacken-docs\n '
21+ ' additional_dependencies:\n '
22+ ' - black==23.3.0\n ' ,
23+ id = 'already correct version' ,
24+ ),
25+ pytest .param (
26+ 'repos:\n '
27+ '- repo: local\n '
28+ ' hooks:\n '
29+ ' - id: mypy\n '
30+ '- repo: https://github.com/nbQA-dev/nbQA\n '
31+ ' rev: 1.9.1\n '
32+ ' hooks:\n '
33+ ' - id: nbqa-mypy\n '
34+ ' additional_dependencies:\n '
35+ ' - mypy==0.123\n ' ,
36+ id = 'local hook shadows supported lib' ,
37+ ),
38+ ),
39+ )
40+ def test_main_noop (tmpdir , s ):
2041 cfg = tmpdir .join ('.pre-commit-config.yaml' )
2142 cfg .write (s )
2243
You can’t perform that action at this time.
0 commit comments