fix[ux]: shorten interface name in error messages#4359
fix[ux]: shorten interface name in error messages#4359sandbubbles wants to merge 10 commits intovyperlang:masterfrom
Conversation
vyper/semantics/types/module.py
Outdated
|
|
||
| def __repr__(self): | ||
| return f"interface {self._id}" | ||
| return f"interface {Path(self._id).stem}" |
There was a problem hiding this comment.
i think we want to change the str implementation, but not repr -- repr should attempt to be injective back to interfaces
There was a problem hiding this comment.
i changed _pp_signature to use str, i think that should be okay cause its only used for error messages
|
|
||
| def __str__(self): | ||
| return self._id | ||
| return Path(self._id).stem |
There was a problem hiding this comment.
what if the type is aliased? e.g.
from ethereum.ercs import IERC20 as BROWNBEAR
There was a problem hiding this comment.
right, that would show the ierc20
There was a problem hiding this comment.
yes, best to show the alias when calling __str__ if it comes from an import, and the InterfaceDef.name if it comes from an InterfaceDef. i looked into this today, and it doesn't seem so trivial to back out the alias once you are already in InterfaceT though.
There was a problem hiding this comment.
confirming with a test:
import lib1
implements: lib1.__interface__
from ethereum.ercs import IERC20 as B
@external
def foobar(token: B):
pass
This will raise with:
vyper.exceptions.InterfaceViolation: Contract does not implement all interface functions: foobar(IERC20)
|
note that if we have a contract like and do The type definition is missing, so is the import. And now we don't even show the path. |
What I did
Change the representation of interfaces in errors to a name instead of a path. Fix #4237.
Edit: remove reference to #4299.
How I did it
Use only a part of
_idas the interface's string representation and use it when printing signature.How to verify it
Test that the interface either shows as
nameorinterface name.Commit message
Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)
Description for the changelog
Cute Animal Picture