From fe4588941bcbd8d075acfd4f22bc9cb0dd2531a0 Mon Sep 17 00:00:00 2001 From: Bram Rodenburg Date: Thu, 31 Aug 2023 17:13:56 +0200 Subject: [PATCH] Bug fix: ignore folders that look like yaml files. --- src/yamlfix/entrypoints/cli.py | 2 +- tests/e2e/test_cli.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/yamlfix/entrypoints/cli.py b/src/yamlfix/entrypoints/cli.py index 61e68b9..9d68252 100644 --- a/src/yamlfix/entrypoints/cli.py +++ b/src/yamlfix/entrypoints/cli.py @@ -31,7 +31,7 @@ def _find_all_yaml_files( file for list_ in files for file in list_ - if not _matches_any_glob(file, dir_, exclude_globs) + if not _matches_any_glob(file, dir_, exclude_globs) and os.path.isfile(file) ] diff --git a/tests/e2e/test_cli.py b/tests/e2e/test_cli.py index 520fe69..cad9015 100644 --- a/tests/e2e/test_cli.py +++ b/tests/e2e/test_cli.py @@ -7,6 +7,7 @@ from pathlib import Path from textwrap import dedent +import py # type: ignore import pytest from _pytest.logging import LogCaptureFixture from click.testing import CliRunner @@ -410,3 +411,12 @@ def test_std_and_file_error(runner: CliRunner, tmp_path: Path) -> None: assert ( str(result.exception) == "Cannot specify '-' and other files at the same time." ) + + +def test_do_not_read_folders_as_files(runner: CliRunner, tmpdir: py.path.local) -> None: + """Skips folders that have a .yml or .yaml extension.""" + tmpdir.mkdir("folder.yml") + + result = runner.invoke(cli, [str(tmpdir)]) + + assert result.exit_code == 0