diff --git a/.gitignore b/.gitignore index 19e0f43..e1a3186 100644 --- a/.gitignore +++ b/.gitignore @@ -496,6 +496,9 @@ poetry.toml # ruff .ruff_cache/ +# LSP config files +pyrightconfig.json + ### SublimeText ### # Cache files for Sublime Text *.tmlanguage.cache diff --git a/pyflybygen/cli/app.py b/pyflybygen/cli/app.py index 300b39b..687dcd5 100644 --- a/pyflybygen/cli/app.py +++ b/pyflybygen/cli/app.py @@ -1,6 +1,7 @@ from pathlib import Path import more_itertools +import pathspec import typer from pyflybygen.cli.common import verbose_callback @@ -49,9 +50,14 @@ def main( help="show the log messages", ), ) -> None: - imports = more_itertools.flatten( - [get_imports(p.read_text()) for p in Path(".").glob("**/*.py")] - ) + + lines = [] + if Path(".gitignore").exists(): + lines.extend(Path(".gitignore").read_text().splitlines()) + spec = pathspec.PathSpec.from_lines("gitwildmatch", lines) + files = Path(".").glob("**/*.py") + files = [file for file in files if not spec.match_file(str(file))] + imports = more_itertools.flatten([get_imports(p.read_text()) for p in files]) print("\n".join(set(imports))) diff --git a/pyproject.toml b/pyproject.toml index 8db8537..012e08c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,8 +30,7 @@ dependencies = [ "anyconfig", "tree_sitter_languages", 'more_itertools', - 'coverage', - 'coverage-rich', + 'pathspec', ] dynamic = ["version"] @@ -58,6 +57,8 @@ dependencies = [ "pytest-rich", "ruff", "black", + 'coverage', + 'coverage-rich', ] [tool.hatch.envs.default.scripts] test = "coverage run -m pytest"