diff --git a/boa/interpret.py b/boa/interpret.py index 17136d3c..dd57133c 100644 --- a/boa/interpret.py +++ b/boa/interpret.py @@ -239,8 +239,16 @@ def loads_partial( dedent: bool = True, compiler_args: dict = None, ) -> VyperDeployer: - name = name or "VyperContract" - filename = filename or "" + if filename is None: + filename = "" + + if name is None: + if isinstance(filename, Path) or ( + isinstance(filename, str) and filename != "" + ): + name = Path(filename).stem + else: + name = "VyperContract" if dedent: source_code = textwrap.dedent(source_code) diff --git a/tests/unitary/contracts/vyper/test_vyper_contract.py b/tests/unitary/contracts/vyper/test_vyper_contract.py index 93d43591..6734377d 100644 --- a/tests/unitary/contracts/vyper/test_vyper_contract.py +++ b/tests/unitary/contracts/vyper/test_vyper_contract.py @@ -87,5 +87,15 @@ def foo() -> bool: c = boa.loads(code, filename="a/b/return_one.vy") - assert c.contract_name == "VyperContract" + assert c.contract_name == "return_one" assert c.filename == "a/b/return_one.vy" + + c = boa.loads(code, filename=None, name="dummy_name") + + assert c.contract_name == "dummy_name" + assert c.filename == "" + + c = boa.loads(code, filename=None, name=None) + + assert c.contract_name == "VyperContract" + assert c.filename == ""