Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type annotations #3688

Open
l0b0 opened this issue Feb 2, 2023 · 5 comments
Open

Type annotations #3688

l0b0 opened this issue Feb 2, 2023 · 5 comments

Comments

@l0b0
Copy link

l0b0 commented Feb 2, 2023

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

@bollwyvl
Copy link
Contributor

bollwyvl commented Feb 7, 2023

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!

@l0b0
Copy link
Author

l0b0 commented Feb 8, 2023

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.

@maartenbreddels
Copy link
Member

Now that mypy 1.0 is out I can pick up ipython/traitlets#818 Again, which is 90% of the typing in ipywidgets (the traits). This is what you want I guess?

@bollwyvl
Copy link
Contributor

bollwyvl commented Feb 8, 2023

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.

@flying-sheep
Copy link
Contributor

This is what you want I guess?

I think the remaining 10% involve some function type annotations and adding a py.typed file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants