ethereum / eth-account

Account abstraction library for web3.py
http://eth-account.readthedocs.io/
MIT License
258 stars 155 forks source link

add mypy to dev dependencies so it has full context when running, set pre-commit to run it #280

Closed pacrob closed 3 months ago

pacrob commented 3 months ago

What was wrong?

The mirrors-mypy pre-commit hook only takes into account the dependencies that are explicitly added in the .pre-commit-config file. This misses additional typing context that may come from other dependencies. Specifically here, running mypy via pre-commit passes, but installing mypy==0.971 and running mypy -p eth_account gives:

site-packages/pydantic_core/_pydantic_core.pyi:64: error: Positional-only parameters are only supported in Python 3.8 and greater
Found 1 error in 1 file (errors prevented further checking)

Bumping to mypy v1.10.0 in the pre-commit hook yields 25 errors, while installing and running locally yields 32.

How fixed

Added mypy==1.10.0 to dev dependencies and set pre-commit to run that instead of its own copy. Fixed new mypy errors.

Many of the errors are related to strict_optional checking. In order to make this PR more focused, I set it to ignore the strict_optional rule, can do that in a dedicated PR.

Todo:

Cute Animal Picture

image