eth-account
eth-account copied to clipboard
Switch on mypy flag disallow_any_generics
What was wrong?
Issue https://github.com/ethereum/eth-account/issues/101: Enable stricter mypy checks
How was it fixed?
I switched on the mypy flag "disallow_any_generics", and fixed resulting mypy errors.
To-Do
- [x] Clean up commit history
- [x] Add entry to the release notes
Cute Animal Picture
Hello! :) Can someone please trigger the CI ?
Done! I'll need to check to see if CI isn't running on purpose 🤔 thanks for the PR!
Hi! I fixed the issue concerning Python 3.7 & 3.8 and added a news fragment. So, if all CI checks pass this time, this PR would be ready for review.
Hi! Can someone please trigger the CI ?
Done! I just did some mucking around with the CircleCI settings, so hopefully it'll just build automatically now 🤞
Hi @kclowes ! I've just cleaned my commits so this PR is ready for review! :) Though the CI was not triggered
I was just reading through some docs here, and the second note in that section says:
If a user submits a pull request to your repository from a fork, but no pipeline is triggered, then the user most likely is following a project fork on their personal account rather than the project itself of CircleCi, causing the jobs to trigger under the user’s personal account and not the organization account. To resolve this issue, have the user unfollow their fork of the project on CircleCI and instead follow the source project. This will trigger their jobs to run under the organization when they submit pull requests.
So maybe try following the ethereum/eth-account project on CircleCI to get the tests to run?
Hi @kclowes ! Thank you for your hints and feedbacks, and sorry for the late answer! I have a few questions:
- According to your suggestion to define:
RLPStructure = Tuple[Tuple[str, Tuple[Hash32, ...]], ...]
I understand the expected address is always a str
(or a ChecksumAddress
which is a str
).
But I also understand the function is_rlp_structured_access_list()
, that checks the access_list
validity, allows also bytes
and bytearray
.
See: is_rlp_structured_access_list()
, and: is_address()
So, my questions are:
- are we sure we always get addresses as str ?
- if yes, wouldn't it make sense to restrict the validity check and allow only
str
/ChecksumAddress
?
Same considerations for the keys for which the validity check seems to allow int
s and not only bytes
/Hash32
?
- Based on you suggestions, it seems we can solve the
cast
issue if we use aTypedDict
as follow:
RLPStructure = Tuple[Tuple[str, Tuple[Hash32, ...]], ...]
RPCDict = TypedDict('RPCDict', {'address': str, 'storageKeys': Tuple[Hash32, ...]})
RPCStructure = Tuple[RPCDict, ...]
I've committed this change and the CI is fine except for Python 3.7 as TypedDict
was added to the standard library only in 3.8.
So, my question is: would it be acceptable to use typing_extensions
like in web3.py ? That would mean to add a dependency in setup.py
since only mypy
uses it at the moment.
closed by #285