eth-account icon indicating copy to clipboard operation
eth-account copied to clipboard

Switch on mypy flag disallow_any_generics

Open Elnaril opened this issue 2 years ago • 8 comments

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

Cute Animal Picture

put a cute animal picture link inside the parentheses

Elnaril avatar Jun 05 '22 10:06 Elnaril

Hello! :) Can someone please trigger the CI ?

Elnaril avatar Jun 05 '22 11:06 Elnaril

Done! I'll need to check to see if CI isn't running on purpose 🤔 thanks for the PR!

kclowes avatar Jun 06 '22 17:06 kclowes

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.

Elnaril avatar Jun 07 '22 09:06 Elnaril

Hi! Can someone please trigger the CI ?

Elnaril avatar Jun 10 '22 06:06 Elnaril

Done! I just did some mucking around with the CircleCI settings, so hopefully it'll just build automatically now 🤞

kclowes avatar Jun 10 '22 19:06 kclowes

Hi @kclowes ! I've just cleaned my commits so this PR is ready for review! :) Though the CI was not triggered

Elnaril avatar Jun 11 '22 13:06 Elnaril

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?

kclowes avatar Jun 15 '22 19:06 kclowes

Hi @kclowes ! Thank you for your hints and feedbacks, and sorry for the late answer! I have a few questions:

  1. 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 ints and not only bytes/Hash32 ?

  1. Based on you suggestions, it seems we can solve the cast issue if we use a TypedDict 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.

Elnaril avatar Jun 24 '22 07:06 Elnaril

closed by #285

pacrob avatar Jul 10 '24 21:07 pacrob