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

Move web3.utils to web3._utils #1033

Merged
merged 5 commits into from
Sep 19, 2018
Merged

Move web3.utils to web3._utils #1033

merged 5 commits into from
Sep 19, 2018

Conversation

dylanjw
Copy link
Contributor

@dylanjw dylanjw commented Aug 29, 2018

What was wrong?

web3.utils contains code for internal use, and that could be made more clear.

How was it fixed?

web3.utils was moved to web3._utils

Cute Animal Picture

image

Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

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

Should we start taking bets on the number of issues that get open for broken imports from the utils module in user's code?

@dylanjw dylanjw force-pushed the _utils branch 2 times, most recently from 54cd2ad to d40314c Compare August 30, 2018 00:12
@Exef
Copy link
Contributor

Exef commented Aug 30, 2018

Can AttributeDict be in different module then? Any project that uses python type hints will be hurt.

@pipermerriam
Copy link
Member

Can AttributeDict be in different module then? Any project that uses python type hints will be hurt.

👍 would you be up for opening a pull request which moves it to a new web3.datastructures module?

@pipermerriam
Copy link
Member

cc @carver regarding attrdict. I see eth-account uses the attrdict library. Should we converge usage to one or the other? IIRC the attrdict library provided more functionality than we needed but there wasn't anything explicitely wrong with it. I do see that we wrap it to make it immutable which is desirable.

@carver
Copy link
Collaborator

carver commented Aug 30, 2018

Can AttributeDict be in different module then? Any project that uses python type hints will be hurt.

Yeah, this sounds like a good reason to wait to move utils until v5. (plus the other reasons we haven't thought of) In case no one noticed, I really hate breaking downstream dependencies in a minor release... :D

@carver
Copy link
Collaborator

carver commented Aug 30, 2018

I see eth-account uses the attrdict library. Should we converge usage to one or the other?

Yeah, I think a small wrapper around it could go in an eth-utils minor release 👍 and then both web3 and eth-account can use the same implementation.

@pipermerriam
Copy link
Member

Maybe we can reliably alias it? I'd be fine special casing this move and adding a deprecation warning to the web3.utils module.

@dylanjw dylanjw added this to the Version 5 Beta milestone Aug 30, 2018
@Exef
Copy link
Contributor

Exef commented Aug 31, 2018

@pipermerriam ok, I'll create PR with the data structures this weekend.

toolz,
transactions,
validation,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@carver @pipermerriam Is this the right way to alias utils -> _utils?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't have a strong opinion on it. Seems okay to me.

module = importlib.util.module_from_spec(spec)
loader.exec_module(module)

from web3._utils import * # noqa: E402,F403,F401
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesnt work how I expect:

>>> from web3.utils.toolz import concat
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'concat'

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.

4 participants