From 2a653a58644b466b1df214809acdd37d07684bd1 Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Sun, 17 Apr 2022 18:20:12 -0500 Subject: [PATCH] fix: handle non alpha chars in contract names (#663) --- src/ape/managers/project/types.py | 4 +++- .../one-interface/contracts/Interface-with-hyphens.json | 3 +++ .../one-interface/contracts/InterfaceWithNumber123.json | 3 +++ .../one-interface/contracts/Interface_with_underscores.json | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/integration/cli/projects/one-interface/contracts/Interface-with-hyphens.json create mode 100644 tests/integration/cli/projects/one-interface/contracts/InterfaceWithNumber123.json create mode 100644 tests/integration/cli/projects/one-interface/contracts/Interface_with_underscores.json diff --git a/src/ape/managers/project/types.py b/src/ape/managers/project/types.py index 2550c70735..64ea0cdedc 100644 --- a/src/ape/managers/project/types.py +++ b/src/ape/managers/project/types.py @@ -43,7 +43,9 @@ def sources(self) -> List[Path]: for extension in self.compiler_manager.registered_compilers: r_ext = extension.replace(".", "\\.") - files.extend(get_all_files_in_directory(self.contracts_folder, pattern=rf"\w+{r_ext}")) + files.extend( + get_all_files_in_directory(self.contracts_folder, pattern=rf"[\w|-]+{r_ext}") + ) return files diff --git a/tests/integration/cli/projects/one-interface/contracts/Interface-with-hyphens.json b/tests/integration/cli/projects/one-interface/contracts/Interface-with-hyphens.json new file mode 100644 index 0000000000..929b853051 --- /dev/null +++ b/tests/integration/cli/projects/one-interface/contracts/Interface-with-hyphens.json @@ -0,0 +1,3 @@ +[ + {"name":"foo","type":"fallback", "stateMutability":"nonpayable"} +] diff --git a/tests/integration/cli/projects/one-interface/contracts/InterfaceWithNumber123.json b/tests/integration/cli/projects/one-interface/contracts/InterfaceWithNumber123.json new file mode 100644 index 0000000000..929b853051 --- /dev/null +++ b/tests/integration/cli/projects/one-interface/contracts/InterfaceWithNumber123.json @@ -0,0 +1,3 @@ +[ + {"name":"foo","type":"fallback", "stateMutability":"nonpayable"} +] diff --git a/tests/integration/cli/projects/one-interface/contracts/Interface_with_underscores.json b/tests/integration/cli/projects/one-interface/contracts/Interface_with_underscores.json new file mode 100644 index 0000000000..929b853051 --- /dev/null +++ b/tests/integration/cli/projects/one-interface/contracts/Interface_with_underscores.json @@ -0,0 +1,3 @@ +[ + {"name":"foo","type":"fallback", "stateMutability":"nonpayable"} +]