mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 18:41:46 +04:00
Fix types bug by using FrozenSet#intersection
Fixes a bug where files are not being recognized based on their `types` using configuration file. In the case of using `types: ['bash', 'sh', 'shell']` in pre-commit-config, those filetypes will not be found, resulting in "no files found" being reported with pre-commit. This persists even when using --all-files flag. Intersection produces predictable results in Python 2.7 and 3.x.
This commit is contained in:
parent
29d66f470d
commit
ff66c20c6e
2 changed files with 7 additions and 4 deletions
|
|
@ -834,15 +834,16 @@ def test_include_exclude_exclude_removes_files(some_filenames):
|
|||
ret = _filter_by_include_exclude(some_filenames, '', r'\.py$')
|
||||
assert ret == {'.pre-commit-hooks.yaml'}
|
||||
|
||||
|
||||
def get_tags_stub(interpreter):
|
||||
return lambda x: tags_from_interpreter(interpreter)
|
||||
|
||||
@pytest.mark.current
|
||||
|
||||
def test_filter_by_types_for_bash_by_interpreter():
|
||||
ret = _filter_by_types(['bash_script'], ['shell', 'sh', 'bash'], [], get_tags=get_tags_stub('bash'))
|
||||
assert ret == ('bash_script',)
|
||||
|
||||
@pytest.mark.current
|
||||
|
||||
def test_filter_by_types_for_python_by_interpreter():
|
||||
ret = _filter_by_types(['script.py'], ['python'], [], get_tags=get_tags_stub('python'))
|
||||
assert ret == ('script.py',)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue