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 annotation #128

Open
martinResearch opened this issue Dec 24, 2022 · 6 comments
Open

adding type annotation #128

martinResearch opened this issue Dec 24, 2022 · 6 comments
Labels

Comments

@martinResearch
Copy link

Thank you for the library.
Unfortunately, having this library not typed prevents mypy from propagating types to do efficient static checks.
Is adding type annotation in the roadmap?
Maybe the stubs in here https://github.com/python/typeshed/tree/main/stdlib/multiprocessing could be reused?

@mmckerns
Copy link
Member

No, adding type annotations is not currently in the roadmap. Thanks for the pointer to multiprocessing from typeshed. I'll have to look into whether it's realistic to use that as a base as opposed to the stdlib multiprocessing.

@martinResearch
Copy link
Author

To be sure there is no confusion: It seems to me that we cannot really oppose the code in here https://github.com/python/cpython/blob/main/Lib/multiprocessing with the code in here https://github.com/python/typeshed/tree/main/stdlib/multiprocessing. It seems that the first one contains the library implementation and does not have any type annotation while the second contains only the annotations and no implementation.

@mmckerns
Copy link
Member

👍 there's no confusion

@Jylpah
Copy link

Jylpah commented Jan 24, 2023

Second vote for type hints. Type hints and mypy make Python programming for more robust since the linter will notice many (most of) issues that would otherwise be runtime errors. But I can image it would be quite an effort to add.

@mcrespoae
Copy link

Following up on this issue: Third vote for type hints.

@chdominguez
Copy link

As a workaround, you can cast multiprocess as multiprocessing for type annotations during development using the typing module:

if typing.TYPE_CHECKING:
    import multiprocessing as mp
else:
    import multiprocess as mp

or

import multiprocess as mp
if typing.TYPE_CHECKING:
   import multiprocessing
   mp = typing.Cast(multiprocessing, mp)

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

No branches or pull requests

5 participants