Add type hints for all packages
See original GitHub issueType hints allow us to perform static type checking, among other things. We could benefit a lot from using them.
This stackoverflow answer does a great job at describing their main benefits.
pyannotate would come in handy if it had support for py3-style annotations, but meanwhile we can add them manually
monkeytype may actually be more useful than pyannotate as it generates py3-style annotations
Definition of done
- type hints for all of
evm
,p2p
, andtrinity
modules. - individual
mypy
CI runs for each of these modules usingmypy --follow-imports=silent --ignore-missing-imports --check-untyped-defs --disallow-incomplete-defs -p <module>
This should not be done as a single pull request, but rather many small ones to iteratively add type hints, slowly expanding the mypy
coverage as hints are added.
Issue Analytics
- State:
- Created 6 years ago
- Comments:29 (13 by maintainers)
Top Results From Across the Web
Python Type Hints: How to Gradually Add Types for Third ...
One place you can apply graduality with Mypy is in the type hints for third party packages. The default course of action is...
Read more >typing — Support for type hints — Python 3.11.1 documentation
This module provides runtime support for type hints. The most fundamental support consists of the types Any , Union , Callable , TypeVar...
Read more >Type hints cheat sheet - mypy 0.991 documentation
Type hints cheat sheet#. This document is a quick cheat sheet showing how to use type annotations for various common types in Python....
Read more >Type hinting in PyCharm - JetBrains
Select a code element. · Press Alt+Enter . · Select Add type hint for .... · Press Enter to complete the action or...
Read more >Automatically add Type Hints in Python - Shreyas' Blog
Type hints help document your code. Traditionally, you would use docstrings if you wanted to document the expected types of a function's ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@pipermerriam I claimed that bounty (or better signaled that I’m working on it) since I already started working on this (https://github.com/ethereum/py-evm/commit/57c6258a69662ee850e83c32fdc039e7fc936e87, https://github.com/ethereum/py-evm/commit/ed05aadfe1ed2196be514a666298cb58ff53c19d, https://github.com/ethereum/py-evm/commit/fb87f47bc7e8550901fa639740dea78676163973) and plan to continue to work on it.
I don’t want to take this away from anyone (so speak up if you happen to be halfway through this or something). I am going to close this. We’ll still be adding type hints, but it will now be something iterative after some of the incoming refactors happen.