Skip to content

Conversation

@wolovim
Copy link
Member

@wolovim wolovim commented Jun 10, 2020

What was wrong?

When instantiating Providers, URI strings appear to be a typical usage pattern, including in our own docs. mypy warns against this though:

w3 = Web3(Web3.HTTPProvider('https://127.0.0.1:8545'))
# or:
w3 = Web3(Web3.WebsocketProvider('ws://127.0.0.1:8546'))

# produces warning:
# Argument 1 has incompatible type "str"; expected "Optional[URI]"

How was it fixed?

URI -> Optional[Union[URI, str]]

Todo:

Cute Animal Picture

@wolovim wolovim changed the title Accept string as Provider arg Accept string type as Provider arg Jun 10, 2020
Copy link
Contributor

@njgheorghita njgheorghita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Yea, it doesn't feel like a fair requirement that users casts the string to URI before passing it into the provider - so this all checks out for me.

In retrospect, as the person who implemented a lot of the types in this library, it feels like a lot of these typing bugs/oversights are my fault, so apologies for any stress / time that you've been caused on my account/sloppiness. Definitely feel free to ping me if I can help with any issues.

@wolovim wolovim merged commit fc69197 into ethereum:master Jun 12, 2020
@wolovim wolovim deleted the http-provider-str branch June 12, 2020 17:59
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