{"action":"created","issue":{"url":"https://api.github.com/repos/ethereum/py-evm/issues/1398","repository_url":"https://api.github.com/repos/ethereum/py-evm","labels_url":"https://api.github.com/repos/ethereum/py-evm/issues/1398/labels{/name}","comments_url":"https://api.github.com/repos/ethereum/py-evm/issues/1398/comments","events_url":"https://api.github.com/repos/ethereum/py-evm/issues/1398/events","html_url":"https://github.com/ethereum/py-evm/issues/1398","id":370501944,"node_id":"MDU6SXNzdWUzNzA1MDE5NDQ=","number":1398,"title":"Add type hints to eth module","user":{"login":"cburgdorf","id":521109,"node_id":"MDQ6VXNlcjUyMTEwOQ==","avatar_url":"https://avatars2.githubusercontent.com/u/521109?v=4","gravatar_id":"","url":"https://api.github.com/users/cburgdorf","html_url":"https://github.com/cburgdorf","followers_url":"https://api.github.com/users/cburgdorf/followers","following_url":"https://api.github.com/users/cburgdorf/following{/other_user}","gists_url":"https://api.github.com/users/cburgdorf/gists{/gist_id}","starred_url":"https://api.github.com/users/cburgdorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cburgdorf/subscriptions","organizations_url":"https://api.github.com/users/cburgdorf/orgs","repos_url":"https://api.github.com/users/cburgdorf/repos","events_url":"https://api.github.com/users/cburgdorf/events{/privacy}","received_events_url":"https://api.github.com/users/cburgdorf/received_events","type":"User","site_admin":false},"labels":[{"id":775886526,"node_id":"MDU6TGFiZWw3NzU4ODY1MjY=","url":"https://api.github.com/repos/ethereum/py-evm/labels/Bounty","name":"Bounty","color":"5319e7","default":false},{"id":631592722,"node_id":"MDU6TGFiZWw2MzE1OTI3MjI=","url":"https://api.github.com/repos/ethereum/py-evm/labels/Good%20First%20Issue","name":"Good First Issue","color":"0e8a16","default":false},{"id":983613604,"node_id":"MDU6TGFiZWw5ODM2MTM2MDQ=","url":"https://api.github.com/repos/ethereum/py-evm/labels/comp:%20evm","name":"comp: evm","color":"bfd4f2","default":false},{"id":983629919,"node_id":"MDU6TGFiZWw5ODM2Mjk5MTk=","url":"https://api.github.com/repos/ethereum/py-evm/labels/effort:%20E2%20days","name":"effort: E2 days","color":"bfe5bf","default":false},{"id":983628230,"node_id":"MDU6TGFiZWw5ODM2MjgyMzA=","url":"https://api.github.com/repos/ethereum/py-evm/labels/prio:%20P3%20important","name":"prio: P3 important","color":"fad8c7","default":false},{"id":983615867,"node_id":"MDU6TGFiZWw5ODM2MTU4Njc=","url":"https://api.github.com/repos/ethereum/py-evm/labels/type:%20refactor","name":"type: refactor","color":"eeeeee","default":false},{"id":983624322,"node_id":"MDU6TGFiZWw5ODM2MjQzMjI=","url":"https://api.github.com/repos/ethereum/py-evm/labels/type:%20security","name":"type: security","color":"eeeeee","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2018-10-16T08:45:15Z","updated_at":"2018-10-23T13:32:55Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"### Background\r\n\r\n[Type hints](https://www.python.org/dev/peps/pep-0484/) allow us to perform static type checking, among other things. They raise the security bar by catching bugs at development time that, without type support, may turn into runtime bugs.\r\n\r\n[This stackoverflow answer](https://stackoverflow.com/questions/32557920/what-are-type-hints-in-python-3-5/32558710#32558710) does a great job at describing their main benefits.\r\n\r\n### What is wrong?\r\n\r\nWe currently enforce type hints for the entire `p2p` and `trinity` package. While the `eth` package does have some type hints already, the coverage isn't at 100 % and while it is agreed up on that new code needs to land with type hints, there is not technical enforcement of this rule in place yet.\r\n\r\nThis needs to be fixed by:\r\n\r\n1. Adding all missing type hints.\r\n2. Enforcing (stricter) type checking in CI\r\n\r\n### How\r\n\r\nThere does exist tooling ([monkeytype](https://engineering.instagram.com/let-your-code-type-hint-itself-introducing-open-source-monkeytype-a855c7284881)) to the generation of type hints for existing code bases. From my personal experience `monkeytype` *can* be helpful but does still require manual fine tuning. Also, manually adding these type hints does serve as a great boost to the general understanding of the code base as it forces one to think about the code.\r\n\r\n1. Run `mypy --follow-imports=silent --warn-unused-ignores --ignore-missing-imports --no-strict-optional --check-untyped-defs --disallow-incomplete-defs --disallow-untyped-defs --disallow-any-generics -p eth`\r\n\r\n2. Eliminate every reported error by adding the right type hint\r\n\r\n3. This should probably be done incrementally in roughly the following steps.\r\n\r\n- `eth.tools` (eligible for payout of 150 DAI)\r\n- `eth.vm` (eligible for payout of 350 DAI)\r\n- everything that is not `eth.vm` (eligible for payout of 300 DAI)\r\n\r\nThe reason for this order is, that it makes it easy to incrementally update the `tox.ini` to enforce stricter rules for such each package without cluttering `tox.ini` too much. \r\n\r\n4. Send frequent pull requests for chunks of work\r\n\r\n### Definition of done\r\n\r\nThis issue is done when the following criteria are met:\r\n\r\n1. The following configuration in `tox.ini` is changed.\r\n\r\nhttps://github.com/ethereum/py-evm/blob/8f74e6b920e1fd4d810724ea842e8a8344ea7094/tox.ini#L107\r\n\r\nIt needs to be:\r\n\r\n```\r\nmypy --follow-imports=silent --warn-unused-ignores --ignore-missing-imports --no-strict-optional --check-untyped-defs --disallow-incomplete-defs --disallow-untyped-defs --disallow-any-generics -p eth\r\n```\r\n\r\n2. Usage of `type: ignore` (silencing the type checker) is minimized and there's a reasonable explanation for its usage \r\n\r\n### Stretch goals\r\n\r\nWhen this issue is done, stretch goals can be applied (and individually get funded) to tighten type support to qualify:\r\n\r\n1. `mypy --strict --follow-imports=silent --ignore-missing-imports --no-strict-optional -p eth -p p2p -p trinity`\r\n\r\n2. `mypy --strict --follow-imports=silent --ignore-missing-imports  -p eth -p p2p -p trinity`\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ethereum/py-evm/issues/comments/432248220","html_url":"https://github.com/ethereum/py-evm/issues/1398#issuecomment-432248220","issue_url":"https://api.github.com/repos/ethereum/py-evm/issues/1398","id":432248220,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMjI0ODIyMA==","user":{"login":"carver","id":205327,"node_id":"MDQ6VXNlcjIwNTMyNw==","avatar_url":"https://avatars0.githubusercontent.com/u/205327?v=4","gravatar_id":"","url":"https://api.github.com/users/carver","html_url":"https://github.com/carver","followers_url":"https://api.github.com/users/carver/followers","following_url":"https://api.github.com/users/carver/following{/other_user}","gists_url":"https://api.github.com/users/carver/gists{/gist_id}","starred_url":"https://api.github.com/users/carver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carver/subscriptions","organizations_url":"https://api.github.com/users/carver/orgs","repos_url":"https://api.github.com/users/carver/repos","events_url":"https://api.github.com/users/carver/events{/privacy}","received_events_url":"https://api.github.com/users/carver/received_events","type":"User","site_admin":false},"created_at":"2018-10-23T13:32:55Z","updated_at":"2018-10-23T13:32:55Z","author_association":"CONTRIBUTOR","body":"Maybe I shouldn't be commenting at 6am but...\r\n\r\nAnother option is to go as far as enumerating all the possibilities, like:\r\n-`pop1int()`\r\n-`pop2int()`\r\n-`pop3int()`\r\n-`pop1bytes()`\r\n-`pop2bytes()`\r\n-`pop3bytes()`\r\n-is that it? Not sure how the \"any type\" hint is used\r\n"}}
{"actor":{"display_login":"carver"}}