-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add type hints to web3.main #1488
Conversation
d993ac2
to
f4ea824
Compare
web3/main.py
Outdated
return self.codec.is_encodable(_type, value) | ||
|
||
@property | ||
def ens(self): | ||
def ens(self) -> Union[ENS, Empty]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if there's a better way to handle this, since it should always be returning only ENS
- but since web3.ens
is set to a default Empty
type in the constructor args, this seems like the only way to make mypy happy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could fix this using a cast
right?
f4ea824
to
1d2797d
Compare
1d2797d
to
1068f8e
Compare
web3/main.py
Outdated
return self.codec.is_encodable(_type, value) | ||
|
||
@property | ||
def ens(self): | ||
def ens(self) -> Union[ENS, Empty]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could fix this using a cast
right?
web3/main.py
Outdated
def __init__( | ||
self, | ||
provider: BaseProvider=None, | ||
middlewares: List[Any]=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be Sequence
web3/main.py
Outdated
self, | ||
provider: BaseProvider=None, | ||
middlewares: List[Any]=None, | ||
modules: Dict[str, Iterable[Any]]=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be Sequence[Any]
.
What was wrong?
Start adding mypy type hints to
web3
- starting withweb3.main
.Todo:
Cute Animal Picture