From fe44b78d24043321b9add576c87c9a4e7a11b151 Mon Sep 17 00:00:00 2001 From: antazoey Date: Wed, 1 May 2024 13:12:03 -0600 Subject: [PATCH] fix: show file name instead of attr in missing source error message (#2045) --- src/ape/managers/project/manager.py | 2 +- tests/functional/test_compilers.py | 2 +- tests/functional/test_project.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index 8af4c8c862..6c581973a9 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -584,7 +584,7 @@ def _handle_attr_or_contract_not_found(self, attr_name: str): continue message = ( - f"{message} However, there is a source file named '{attr_name}', " + f"{message} However, there is a source file named '{file.name}', " "did you mean to reference a contract name from this source file?" ) file_check_appended = True diff --git a/tests/functional/test_compilers.py b/tests/functional/test_compilers.py index e967f7bc11..7865d41962 100644 --- a/tests/functional/test_compilers.py +++ b/tests/functional/test_compilers.py @@ -29,7 +29,7 @@ def test_missing_compilers_error_message(project_with_source_files_contract, sen missing_exts = project_with_source_files_contract.extensions_with_missing_compilers() expected = ( r"ProjectManager has no attribute or contract named 'ContractA'\. " - r"However, there is a source file named 'ContractA', " + r"However, there is a source file named 'ContractA.sol', " r"did you mean to reference a contract name from this source file\? " r"Else, could it be from one of the missing compilers for extensions: " rf'{", ".join(sorted(missing_exts))}\?' diff --git a/tests/functional/test_project.py b/tests/functional/test_project.py index 4dd1ed0f65..be4f0568dd 100644 --- a/tests/functional/test_project.py +++ b/tests/functional/test_project.py @@ -495,7 +495,7 @@ def test_getattr_contract_not_exists(project): expected = ( r"ProjectManager has no attribute or contract named " r"'ThisIsNotAContractThatExists'. However, there is a source " - r"file named 'ThisIsNotAContractThatExists', did you mean to " + r"file named 'ThisIsNotAContractThatExists\.foo', did you mean to " r"reference a contract name from this source file\? " r"Else, could it be from one of the missing compilers for extensions:.*\?" )