ethereum / eth-abi

Ethereum ABI utilities for python
MIT License
241 stars 268 forks source link

Type hint support broken: missing py.typed #106

Closed feuGeneA closed 5 years ago

feuGeneA commented 5 years ago

image

What was wrong?

I have a package which uses eth_abi, and which lints its code with mypy. Telling mypy to ignore the eth_abi import (import ... # type: ignore) obviously works fine, but when I remove that ignore, I get the following message:

test.py:13: error: Cannot find module named 'eth_abi'
test.py:13: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports" flag would help)

The line in question is simply:

from eth_abi import encode_abi

How can it be fixed?

Per PEP 484, include a file py.typed in the package. In my local environment, I was able to solve the problem by simply doing touch ~/.pythonz/lib/python3.7/site-packages/eth_abi-1.2.0-py3.7.egg/eth_abi/py.typed.