ipywidgets
ipywidgets copied to clipboard
Type annotations
Problem
Type annotations would allow developers and IDEs to easily reason about how ipywidgets is meant to be used.
Proposed Solution
Add type annotations to the point where all the Python code in this repo passes mypy inspection, and ideally mypy --strict.
Additional context
- Example projects with
mypy --strictcompliance:- https://github.com/linz/geostore/
- https://gitlab.com/engmark/mypy-exercises
- https://github.com/linz/emergency-management-tools/
Probably a dupe of #3676.
mypy is widely used across the jupyter ecosystem, and ipywidgets is one of the "leaves" that has been hard to reason about until its upstreams are really solid.
PRs welcome, of course!
I'm unfamiliar with this code base, and I'm only using it for a project at work, so I probably can't justify spending the time to do it myself. That said, although this is technically a dupe I'd consider it orthogonal to the docstring styling which is the core of #3676.
Now that mypy 1.0 is out I can pick up https://github.com/ipython/traitlets/pull/818 Again, which is 90% of the typing in ipywidgets (the traits). This is what you want I guess?
orthogonal to the docstring styling
To the initial point of developers and IDEs: type hints and in-code help, as delivered from docstrings, are very tightly coupled for most IDE integrations (e.g. the language server protocol) and the jupyter messaging protocol (completion and inspection).
While moving forward on type hints would put more squiggly red lines in the editor, standardizing what a user sees when hovering over these tokens substantially improves the overall experience, which also extends to the documentation.
This is what you want I guess?
I think the remaining 10% involve some function type annotations and adding a py.typed file