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

Adoption of type-hints #541

Open
priba opened this issue Aug 2, 2024 · 5 comments
Open

Adoption of type-hints #541

priba opened this issue Aug 2, 2024 · 5 comments

Comments

@priba
Copy link

priba commented Aug 2, 2024

The adoption of type-hints is becoming popular in the python community. Are there plans to add type hints within cloudpickle?

@ogrisel
Copy link
Contributor

ogrisel commented Aug 5, 2024

I have no strong opinion on this matter but I am worried about the extra maintenance effort. How would you benefit from cloudpickle using type-hints? Do you use cloudpickle as a library in another library that uses type-hints?

@aldanor
Copy link

aldanor commented Aug 5, 2024

Having cloudpickle in any type-verified project (e.g. using mypy) results in errors like

cloudpickle: module is installed, but missing library stubs or py.typed marker [import-untyped]

forcing you to add cloudpickle to type-ignore list in pyproject.toml, which isn't nice.

Also, having type annotations in the library itself may prevent some downstream user errors (e.g. they will have their ide/editor highlight type mismatches if any).

@aldanor
Copy link

aldanor commented Aug 5, 2024

but I am worried about the extra maintenance effort.

I don't think there's too much maintenance effort - it's basically adding type annotations around all public-facing functions/methods/types, and then adding an empty py.typed file.

For bonus points, you'd want to run mypy in CI to make sure that type annotations are internally consistent.

@priba
Copy link
Author

priba commented Aug 7, 2024

Agree with @aldanor, he explained my current issues.

I am adding cloudpickle into type-ignore so mypy does not complain. I assume several people are dealing with this.

@ogrisel
Copy link
Contributor

ogrisel commented Oct 14, 2024

I don't think there's too much maintenance effort - it's basically adding type annotations around all public-facing functions/methods/types, and then adding an empty py.typed file.

We can indeed start with a minimal PR that adds type annotations to the public API of cloudpickle only and later decide if we want to generalize type annotations to private functions/methods for follow-up PRs.

If there are any volunteer in the room, feel free to open a PR for the first part.

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

3 participants