mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 10:31: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
|
|
@ -53,10 +53,12 @@ def _filter_by_types(filenames,
|
|||
exclude_types,
|
||||
get_tags=tags_from_path):
|
||||
types, exclude_types = frozenset(types), frozenset(exclude_types)
|
||||
valid_types = types - exclude_types
|
||||
|
||||
ret = []
|
||||
for filename in filenames:
|
||||
tags = get_tags(filename)
|
||||
if tags >= types and not tags & exclude_types:
|
||||
tags = frozenset(get_tags(filename))
|
||||
if len(valid_types.intersection(tags)) > 0:
|
||||
ret.append(filename)
|
||||
return tuple(ret)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue