-
Notifications
You must be signed in to change notification settings - Fork 179
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
Replace attrdict with NamedTuple #76
Replace attrdict with NamedTuple #76
Conversation
24654d5
to
007e8ea
Compare
review ping @pipermerriam |
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 would be a breaking change and while I'm 👍 on moving this direction, I don't think we an do it immediately. It doesn't appear that this is fixed upstream, nor has there been a release in about 11 months.
I'd recommend pursuing an upstream fix for this first and seeing if the library maintainers can get it merged and released so we can address this without a major bump.
Second option is to use something like this and vendor it for the time being: https://github.com/ethereum/web3.py/blob/c1c80dba4d9c203af7a4963bf1ce5e922f1172da/web3/datastructures.py
I'm good with us eventually switching to a NamedTuple
but I consider this library to be somewhat foundational and thus a major version bump in it is going to need to be taken carefully and probably shouldn't happen until sometime in January when all this holiday nonsense has passed.
The inactivity there was part of the reason why I believe it is not worth to try to get this fixed upstream. I wouldn't expect to this to result in an upstream release in a short time frame which is why I thought it is better to fix it on our on end. Especially if we consider that modern Python has no need for that library any more.
But wouldn't that be as much of a breaking change as just going with Someone calling
Yeah, no rush. I'd probably say, let's just wait and cut a new major release some time in January. |
It is a breaking change because named tuples don't support dictionary style key retrieval. Whatever we return needs to support both attribute and string-based key lookups via the standard |
Ah! That makes sense. Thanks for clarifying. |
2c: probably means there needs to be a test for this. As to the previous
There will be no release: the ustream repo has been archived by the owner. On a brighter side, the deprecation has been moved to Python 3.9 since original post:
|
Considering that the project seems dead, I'd argue we should just cut a new major release and migrate Trinity to it. We can continue to backport further changes into the |
322feb6
to
5f2e7b2
Compare
I have updated the change to preserve the current behavior of providing index access. I also tuned the tests to cover indexing access. What do you think about this @pipermerriam ? I'd love to get this fixed as it's currently the main driver of nasty warnings in Trinity. |
@carver any thoughts on the breaking change here. I'm inclined to |
@pipermerriam what's the remaining breaking change now that I added index access support? |
@@ -507,7 +508,7 @@ def sign_message(self, signable_message: SignableMessage, private_key): | |||
:param private_key: the key to sign the message with | |||
:type private_key: hex str, bytes, int or :class:`eth_keys.datatypes.PrivateKey` | |||
:returns: Various details about the signature - most importantly the fields: v, r, and s | |||
:rtype: ~eth_account.datastructures.AttributeDict | |||
:rtype: ~eth_account.datastructures.SignedMessage |
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.
Interesting that the doctests (which were supposedly checked recently) didn't catch that the returned value changes below.
I would expect there to be a number of places in the docs where this would change.
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 just spent 1,5 hour to depuzzle this and here's the best I know so far:
-
We never had any doctest running in this repo so far. I wasn't able to find a single CI run that ran any doctests (even though they exist)
-
Then I found Doctests for Account and other general doc cleanup #94 which seems to fix this (it reports running 50 tests)
I'd happily rebase this on top of #94 but in case #94 needs more time to finish it should be easy to rebase that one on top of these changes, too.
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 totally lost track of #94. I just updated and it should be ready to merge. @cburgdorf I'm happy to pull your changes into #94, or vice versa, whatever is easier! Just let me know.
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.
@kclowes I don't have merge rights in this repo. If you have merge rights then feel free to merge both PRs in any preferred order.
For very type-conscious consumers, it could still break their tests. Maybe their mypy tests or doctests. (Maybe even projects like web3.py?) I have always preferred a more duck-typing approach, but with the strict-typing tactic used in a lot of our projects, we might still be forced to do it is a v0 minor release (which we have been using to indicate a breaking change). I still think it's a good change to keep the indexing access to minimize the cost of updating downstream projects. 👍 |
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.
👍 didn't see that the breaking change had been fixed. 👍
5f2e7b2
to
f1d68de
Compare
@cburgdorf I merged the other PR, mind rebasing to make sure everything is still good here and then I'll get this merged. |
f1d68de
to
94dabda
Compare
@pipermerriam rebased and ready to 🚢 |
@carver can you handle the release? |
Seems like a fuzzy gray area of incompatibility. I'll just be sure to highlight it in the release notes. I just checked web3.py, and it doesn't have any reference to So I'll go ahead and release this as a patch release. |
It's a little late today, so I'll aim for Thursday morning. |
* remove gitter, testing setup, and pandoc sections, add quotes to dev install
* remove gitter, testing setup, and pandoc sections, add quotes to dev install
What was wrong?
The usage of
attrdict
dependency was causing a deprecation warning.How was it fixed?
Replaced with
NamedTuple
which should have the positive side effect of a stronger guarantee of immutability.Cute Animal Picture