You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While adding a simple labextension won't benefit from type checking, as soon as a REST API, widget, etc. is added, it becomes powerful tool for finding actual bugs, learning about how your code (and your dependencies' code) actually works, and particularly useful when upgrading to a new version of a well-typed upstream (e.g. jupyter_server).
Proposed Solution
Add:
type hints in generated .py files
ship py.typed
pyproject.toml
Typing :: Typed trove classifier
[tool.mypy] with pretty strict defaults
There are of course other typecheckers, and choice is good, but of the typed upstreams, most rely on mypy.
By just being present in a well-known location, the settings will get picked up in some IDEs (even if another typecheker is used), helping folk fix typing issues per-keystroke.
As an option, be able to add a mypy check to... whatever, whether it's make, just GHA, pre-commit, some hatch env-in-env monstrosity or whatever is suggested to folk by this template this week.
Additional context
While jupyterlab_serverdoes ship py.typed, jupyterlab itself does not.
4.0 should probably add type hints and ship py.typed, but luckily, it isn't imported in most well-behaved extensions
The text was updated successfully, but these errors were encountered:
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋
Welcome to the Jupyter community! 🎉
bollwyvl
changed the title
Adding type hints and ship py.typed
Adding type hints and ship py.typed, mypy config
Apr 19, 2023
Problem
While adding a simple labextension won't benefit from type checking, as soon as a REST API, widget, etc. is added, it becomes powerful tool for finding actual bugs, learning about how your code (and your dependencies' code) actually works, and particularly useful when upgrading to a new version of a well-typed upstream (e.g.
jupyter_server
).Proposed Solution
Add:
.py
filespy.typed
pyproject.toml
Typing :: Typed
trove classifier[tool.mypy]
with pretty strict defaultsThere are of course other typecheckers, and choice is good, but of the typed upstreams, most rely on
mypy
.By just being present in a well-known location, the settings will get picked up in some IDEs (even if another typecheker is used), helping folk fix typing issues per-keystroke.
As an option, be able to add a
mypy
check to... whatever, whether it'smake
, just GHA, pre-commit, some hatch env-in-env monstrosity or whatever is suggested to folk by this template this week.Additional context
While
jupyterlab_server
does shippy.typed
,jupyterlab
itself does not.4.0 should probably add type hints and ship
py.typed
, but luckily, it isn't imported in most well-behaved extensionsThe text was updated successfully, but these errors were encountered: