Skip to content

Commit 31e751f

Browse files
authored
Merge pull request pre-commit#767 from pre-commit/consistent_ordering
Consistent ordering of filenames
2 parents 507c327 + 5b6a5ab commit 31e751f

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

pre_commit/commands/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ def _hook_msg_start(hook, verbose):
3838

3939
def _filter_by_include_exclude(filenames, include, exclude):
4040
include_re, exclude_re = re.compile(include), re.compile(exclude)
41-
return {
41+
return [
4242
filename for filename in filenames
4343
if (
4444
include_re.search(filename) and
4545
not exclude_re.search(filename) and
4646
os.path.lexists(filename)
4747
)
48-
}
48+
]
4949

5050

5151
def _filter_by_types(filenames, types, exclude_types):

tests/commands/run_test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -770,39 +770,39 @@ def test_fail_fast(
770770
def some_filenames():
771771
return (
772772
'.pre-commit-hooks.yaml',
773-
'pre_commit/main.py',
774-
'pre_commit/git.py',
775773
'im_a_file_that_doesnt_exist.py',
774+
'pre_commit/git.py',
775+
'pre_commit/main.py',
776776
)
777777

778778

779779
def test_include_exclude_base_case(some_filenames):
780780
ret = _filter_by_include_exclude(some_filenames, '', '^$')
781-
assert ret == {
781+
assert ret == [
782782
'.pre-commit-hooks.yaml',
783-
'pre_commit/main.py',
784783
'pre_commit/git.py',
785-
}
784+
'pre_commit/main.py',
785+
]
786786

787787

788788
@xfailif_no_symlink
789789
def test_matches_broken_symlink(tmpdir): # pragma: no cover (non-windows)
790790
with tmpdir.as_cwd():
791791
os.symlink('does-not-exist', 'link')
792792
ret = _filter_by_include_exclude({'link'}, '', '^$')
793-
assert ret == {'link'}
793+
assert ret == ['link']
794794

795795

796796
def test_include_exclude_total_match(some_filenames):
797797
ret = _filter_by_include_exclude(some_filenames, r'^.*\.py$', '^$')
798-
assert ret == {'pre_commit/main.py', 'pre_commit/git.py'}
798+
assert ret == ['pre_commit/git.py', 'pre_commit/main.py']
799799

800800

801801
def test_include_exclude_does_search_instead_of_match(some_filenames):
802802
ret = _filter_by_include_exclude(some_filenames, r'\.yaml$', '^$')
803-
assert ret == {'.pre-commit-hooks.yaml'}
803+
assert ret == ['.pre-commit-hooks.yaml']
804804

805805

806806
def test_include_exclude_exclude_removes_files(some_filenames):
807807
ret = _filter_by_include_exclude(some_filenames, '', r'\.py$')
808-
assert ret == {'.pre-commit-hooks.yaml'}
808+
assert ret == ['.pre-commit-hooks.yaml']

0 commit comments

Comments
 (0)