From 8b62f45c5ef761e3c633ff2ac50a82a2eec3e566 Mon Sep 17 00:00:00 2001 From: Sergii Dymchenko Date: Wed, 23 Aug 2023 18:09:22 -0700 Subject: [PATCH] Don't gather dirs ending .py --- libcst/codemod/_cli.py | 5 ++++- libcst/tests/test_e2e.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libcst/codemod/_cli.py b/libcst/codemod/_cli.py index 61e34e1c4..3958ef05e 100644 --- a/libcst/codemod/_cli.py +++ b/libcst/codemod/_cli.py @@ -90,7 +90,10 @@ def gather_files( ret.extend( str(p) for p in Path(fd).rglob("*.py*") - if str(p).endswith("py") or (include_stubs and str(p).endswith("pyi")) + if Path.is_file(p) + and ( + str(p).endswith("py") or (include_stubs and str(p).endswith("pyi")) + ) ) return sorted(ret) diff --git a/libcst/tests/test_e2e.py b/libcst/tests/test_e2e.py index ecdc23baa..219192fbe 100644 --- a/libcst/tests/test_e2e.py +++ b/libcst/tests/test_e2e.py @@ -48,6 +48,9 @@ def test_leaky_codemod(self) -> None: # File that should not be modified other = tmp / "other.py" other.touch() + # Just a dir named "dir.py", should be ignored + adir = tmp / "dir.py" + adir.mkdir() # Run command command_instance = PrintToPPrintCommand(CodemodContext())