RFC: Use type hints in larq source codeSee original GitHub issue
Python 3.6 and above supports type hints and optional statically typing of Python code. Since its introduction is has seen a lot of adoption in many Python projects in particular in larger code bases. Type hints are completely optional and are stripped by the Python parser before runtime.
I am not the only one @plumerai anymore who likes type hints for Python and we only support Python 3.6+ already so I’d like to discuss if we should introduce type hints to the
larq code base. I have never used typings in a big project, but below is a list of some pros and cons I can think of on top of my head.
- Makes it easy to reason about the code due to the self documenting nature of statically typed functions
- Helps with code review
- Can catch subtle bugs of in places of insufficient code coverage
- Has good integrations for editors that help with autocomplete and linting
- TensorFlow doesn’t use type hints so I don’t know how well type stubs are maintained
- Needs additional setup on CI and to maintain type stubs
- Might be confusing for novice Python users since it adds new syntax to the
- Created 4 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
Sounds like a great idea! One small remark: as TensorFlow currently doesn’t have typehints I would prefer to keep all examples provided in the documentation free of typehints, so as to not raise the threshold for users who are not familiar with them.
The most important thing is for the external API to have type hints so that this gets picked up in editors/IDEs; any private methods or tests don’t need them, and examples definitely don’t.