From 22d3cb1c341f1c7ab5993c23019f51fe9562fe89 Mon Sep 17 00:00:00 2001 From: antazoey Date: Wed, 8 May 2024 14:03:55 -0600 Subject: [PATCH] fix: .cache wasnt ignored (#2076) --- src/ape/cli/arguments.py | 2 +- src/ape/utils/misc.py | 2 +- tests/functional/test_cli.py | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ape/cli/arguments.py b/src/ape/cli/arguments.py index ab18d9a4e5..99225ae279 100644 --- a/src/ape/cli/arguments.py +++ b/src/ape/cli/arguments.py @@ -109,7 +109,7 @@ def exclude_patterns(self) -> List[str]: return self.config_manager.get_config("compile").exclude or [] def do_exclude(self, path: Union[Path, str]) -> bool: - name = path if isinstance(path, str) else path.name + name = path if isinstance(path, str) else str(path) if name not in self.exclude_list: self.exclude_list[name] = any(fnmatch(name, p) for p in self.exclude_patterns) diff --git a/src/ape/utils/misc.py b/src/ape/utils/misc.py index 977ce12825..b86a6692b1 100644 --- a/src/ape/utils/misc.py +++ b/src/ape/utils/misc.py @@ -33,7 +33,7 @@ DEFAULT_TRANSACTION_TYPE = 0 DEFAULT_MAX_RETRIES_TX = 20 SOURCE_EXCLUDE_PATTERNS = ( - ".cache", + "**/.cache/**", ".DS_Store", ".gitkeep", "**/.build/**/*.json", diff --git a/tests/functional/test_cli.py b/tests/functional/test_cli.py index 76b255c6d1..fe9c98a8e9 100644 --- a/tests/functional/test_cli.py +++ b/tests/functional/test_cli.py @@ -465,9 +465,17 @@ def test_contract_file_paths_handles_exclude(project_with_contract, runner, cont cfg = project_with_contract.config_manager.get_config("compile") failmsg = "Setup failed - missing exclude config (set in ape-config.yaml)." assert "*Excl*" in cfg.exclude, failmsg + + # make a .cache file to show it is ignored. + cache_file = project_with_contract.contracts_folder / ".cache" / "thing.json" + cache_file.parent.mkdir(parents=True, exist_ok=True) + cache_file.write_text("FAILS IF LOADED") + result = runner.invoke(contracts_paths_cmd, "contracts") assert "Exclude.json" not in result.output assert "ExcludeNested.json" not in result.output + # Ensure .cache always ignored! + assert ".cache" not in result.output @pytest.mark.parametrize("name", ("contracts/subdir", "subdir"))