Skip to content
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

Merged
merged 2 commits into from
Nov 4, 2019

Conversation

njgheorghita
Copy link
Contributor

@njgheorghita njgheorghita commented Nov 1, 2019

What was wrong?

Start adding mypy type hints to web3 - starting with web3.main.

Todo:

Cute Animal Picture

image

web3/main.py Outdated
return self.codec.is_encodable(_type, value)

@property
def ens(self):
def ens(self) -> Union[ENS, Empty]:
Copy link
Contributor Author

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.

Copy link
Member

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
return self.codec.is_encodable(_type, value)

@property
def ens(self):
def ens(self) -> Union[ENS, Empty]:
Copy link
Member

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,
Copy link
Member

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,
Copy link
Member

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].

@njgheorghita njgheorghita merged commit 6c0256a into ethereum:master Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants