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
Merged

Conversation

@njgheorghita
Copy link
Contributor

njgheorghita commented Nov 1, 2019

What was wrong?

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

Todo:

Cute Animal Picture

image

@njgheorghita njgheorghita force-pushed the njgheorghita:type-hints-main branch from d993ac2 to f4ea824 Nov 1, 2019
return self.codec.is_encodable(_type, value)

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

This comment has been minimized.

Copy link
@njgheorghita

njgheorghita Nov 1, 2019

Author Contributor

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.

This comment has been minimized.

Copy link
@pipermerriam

pipermerriam Nov 1, 2019

Member

I think you could fix this using a cast right?

@njgheorghita njgheorghita force-pushed the njgheorghita:type-hints-main branch from f4ea824 to 1d2797d Nov 1, 2019
@njgheorghita njgheorghita force-pushed the njgheorghita:type-hints-main branch from 1d2797d to 1068f8e Nov 1, 2019
@njgheorghita njgheorghita requested review from kclowes and pipermerriam Nov 1, 2019
return self.codec.is_encodable(_type, value)

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

This comment has been minimized.

Copy link
@pipermerriam

pipermerriam Nov 1, 2019

Member

I think you could fix this using a cast right?

def __init__(
self,
provider: BaseProvider=None,
middlewares: List[Any]=None,

This comment has been minimized.

Copy link
@pipermerriam

pipermerriam Nov 1, 2019

Member

This should probably be Sequence

self,
provider: BaseProvider=None,
middlewares: List[Any]=None,
modules: Dict[str, Iterable[Any]]=None,

This comment has been minimized.

Copy link
@pipermerriam

pipermerriam Nov 1, 2019

Member

This should probably be Sequence[Any].

@njgheorghita njgheorghita merged commit 6c0256a into ethereum:master Nov 4, 2019
29 checks passed
29 checks passed
ci/circleci: docs Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: py36-core Your tests passed on CircleCI!
Details
ci/circleci: py36-ens Your tests passed on CircleCI!
Details
ci/circleci: py36-ethpm Your tests passed on CircleCI!
Details
ci/circleci: py36-integration-ethtester-pyevm Your tests passed on CircleCI!
Details
ci/circleci: py36-integration-goethereum-http-1.7.2 Your tests passed on CircleCI!
Details
ci/circleci: py36-integration-goethereum-http-1.8.22 Your tests passed on CircleCI!
Details
ci/circleci: py36-integration-goethereum-ipc-1.7.2 Your tests passed on CircleCI!
Details
ci/circleci: py36-integration-goethereum-ipc-1.8.22 Your tests passed on CircleCI!
Details
ci/circleci: py36-integration-goethereum-ws-1.7.2 Your tests passed on CircleCI!
Details
ci/circleci: py36-integration-goethereum-ws-1.8.22 Your tests passed on CircleCI!
Details
ci/circleci: py36-integration-parity-http Your tests passed on CircleCI!
Details
ci/circleci: py36-integration-parity-ipc Your tests passed on CircleCI!
Details
ci/circleci: py36-integration-parity-ws Your tests passed on CircleCI!
Details
ci/circleci: py37-core Your tests passed on CircleCI!
Details
ci/circleci: py37-ens Your tests passed on CircleCI!
Details
ci/circleci: py37-ethpm Your tests passed on CircleCI!
Details
ci/circleci: py37-integration-ethtester-pyevm Your tests passed on CircleCI!
Details
ci/circleci: py37-integration-goethereum-http-1.7.2 Your tests passed on CircleCI!
Details
ci/circleci: py37-integration-goethereum-http-1.8.22 Your tests passed on CircleCI!
Details
ci/circleci: py37-integration-goethereum-ipc-1.7.2 Your tests passed on CircleCI!
Details
ci/circleci: py37-integration-goethereum-ipc-1.8.22 Your tests passed on CircleCI!
Details
ci/circleci: py37-integration-goethereum-ws-1.7.2 Your tests passed on CircleCI!
Details
ci/circleci: py37-integration-goethereum-ws-1.8.22 Your tests passed on CircleCI!
Details
ci/circleci: py37-integration-parity-http Your tests passed on CircleCI!
Details
ci/circleci: py37-integration-parity-ipc Your tests passed on CircleCI!
Details
ci/circleci: py37-integration-parity-ws Your tests passed on CircleCI!
Details
continuous-documentation/read-the-docs Read the Docs build succeeded!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.