-
Notifications
You must be signed in to change notification settings - Fork 250
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
dev: change type of branch node subnodes #1066
base: master
Are you sure you want to change the base?
Conversation
bcef93c
to
2a3b61a
Compare
Does the annotation get enforced? If not, I'd prefer the tuple with 16 elements, probably as a proper type or type alias. |
The Annotation is not enforced. It's only a "hint" for the reader that it expects 16 elements. We could create a proper type that Perhaps something like:
|
Kinda ugly, but I don't see a shorter way of making the type annotation meaningful to mypy. Let's go with the sixteen |
done :) |
Hi @SamWilsn, any chance you can help me understand why CI is failing ? |
What was wrong?
The type for the BranchNode's subnodes was
List[rlp.Extended]
. While this is not inherently wrong, a more suitable type would be a tuple with 16 rlp.Extended elements, each representing a BranchNode of the trie, as there's no intent to mutate the subnodes after instantiation.Related to Issue #
How was it fixed?
Changed to
Annotated[Tuple[rlp.Extended, ...], 16]
. Also open to just repeating 16 times the rlp.Extended argument, but using an annotation sounds more convenient rather than repeating. The annotation conveys at type hint that the tuple is of size 16.Cute Animal Picture
Our beloved moodeng friend