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

Adding type hints and ship py.typed, mypy config #6

Open
bollwyvl opened this issue Apr 19, 2023 · 1 comment
Open

Adding type hints and ship py.typed, mypy config #6

bollwyvl opened this issue Apr 19, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@bollwyvl
Copy link

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:

  • 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_server does 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

@bollwyvl bollwyvl added the enhancement New feature or request label Apr 19, 2023
@welcome
Copy link

welcome bot commented Apr 19, 2023

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.
welcome
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 bollwyvl changed the title Adding type hints and ship py.typed Adding type hints and ship py.typed, mypy config Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant