Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pre_commit/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ def by_types(
types = frozenset(types)
types_or = frozenset(types_or)
exclude_types = frozenset(exclude_types)
if not types and not types_or and not exclude_types:
# We're not filtering on types, just return all filenames.
for filename in names:
yield filename
return
for filename in names:
tags = self._types_for_file(filename)
if (
Expand Down
14 changes: 14 additions & 0 deletions tests/commands/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,20 @@ def test_classifier_empty_types_or(tmpdir):
assert tuple(for_file) == ('bar',)


def test_classifier_no_types(tmpdir):
tmpdir.join('bar').ensure()
os.symlink(tmpdir.join('bar'), tmpdir.join('foo'))
with tmpdir.as_cwd():
classifier = Classifier(('foo', 'bar'))
res = classifier.by_types(
classifier.filenames,
types=[],
types_or=[],
exclude_types=[],
)
assert tuple(res) == ('foo', 'bar')


@pytest.fixture
def some_filenames():
return (
Expand Down
Loading