Repository: eth-brownie/brownie
Issue: Need "brownie clean" ? Found issues when changing name and signature of contracts

* `brownie` Version: 1.1.0
* `ganache-cli` Version: 
* `solc` Version: 0.5.12
* Python Version: 3.7.0
* OS: win

I am really enjoying working with this tool. I report a small bug.

### What was wrong?

I found issues when changing the signature of a contract that already has some tests. Happens when you change the signature of a contract that already has some tests working. Then got worse when I tried new names for the contract, the old contract name was still hanging around somewhere. I solved cloning again the repo somewhere.

In the following output, the contract name 'IdentityMasterService2' is no longer used anywhere.

Maybe this can be solved including some 'brownie clean' command for cleaning caches or something.

Output:

 brownie compile
Brownie v1.1.0 - Python development framework for Ethereum

  File "c:\\python37\\lib\\site-packages\\brownie\\_cli\\__main__.py", line 55, in main
    importlib.import_module(f"brownie._cli.{args['<command>']}").main()
  File "c:\\python37\\lib\\site-packages\\brownie\\_cli\\compile.py", line 28, in main
    project.load(project_path)
  File "c:\\python37\\lib\\site-packages\\brownie\\project\\main.py", line 366, in load
    return Project(name, project_path)
  File "c:\\python37\\lib\\site-packages\\brownie\\project\\main.py", line 123, in __init__
    self.load()
  File "c:\\python37\\lib\\site-packages\\brownie\\project\\main.py", line 137, in load
    changed = self._get_changed_contracts()
  File "c:\\python37\\lib\\site-packages\\brownie\\project\\main.py", line 163, in _get_changed_contracts
    changed_set: Set = set(self._sources.get_source_path(i) for i in final)
  File "c:\\python37\\lib\\site-packages\\brownie\\project\\main.py", line 163, in <genexpr>
    changed_set: Set = set(self._sources.get_source_path(i) for i in final)
  File "c:\\python37\\lib\\site-packages\\brownie\\project\\sources.py", line 58, in get_source_path
    return self._contracts[contract_name]["path"]
KeyError: 'IdentityMasterService2'

If you need more detailed info let me know. Thanks.


Changed files:
brownie/project/main.py

diff --git a/brownie/project/main.py b/brownie/project/main.py
index 0d88db39..250bdc57 100644
--- a/brownie/project/main.py
+++ b/brownie/project/main.py
@@ -121,16 +121,14 @@ class Project(_ProjectBase):
         super().__init__(name, contract_sources, project_path)
         self._path: Path = project_path
 
+        contract_list = self._sources.get_contract_list()
         for path in list(project_path.glob("build/contracts/*.json")):
             try:
                 with path.open() as fp:
                     build_json = json.load(fp)
             except json.JSONDecodeError:
                 build_json = {}
-            if (
-                not set(BUILD_KEYS).issubset(build_json)
-                or not project_path.joinpath(build_json["sourcePath"]).exists()
-            ):
+            if not set(BUILD_KEYS).issubset(build_json) or path.stem not in contract_list:
                 path.unlink()
                 continue
             self._build._add(build_json)