noxdafox / pebble

Multi threading and processing eye-candy.
GNU Lesser General Public License v3.0
525 stars 49 forks source link

Add type-hinting to concurrent decorators. Bump to Python 3.9. #139

Open emiliadecaudin opened 1 week ago

emiliadecaudin commented 1 week ago

I've confirmed before submitting this pull request that all tests pass.

This pull request does two things:

I am a big fan of this package and would be eager to help add more type-hinting for the rest of the package as well as adding mypy/ruff linting!

JoaquimEsteves commented 1 week ago

Big fan of this PR. However I'm against the bump to 3.9.

This is a library after all, the core functionality is not affected and so bumping will only harm users stuck on older python versions.

There is a way out of this, you could either split the types into a stub file or use typing_extensions like so:

from typing import TYPE_CHECKING:
if TYPE_CHECKING:
    # look ma. No runtime errors on older python!
    from typing_extensions import ...etc
emiliadecaudin commented 1 week ago

Understood; I don't have experience writing type-safe code before 3.9 so I'm less familiar with how to write proper type hints before the changes introduced in that version. I'm at a conference right now but I will try to dive in after this week and test against 3.7.

JoaquimEsteves commented 1 week ago

Understood; I don't have experience writing type-safe code before 3.9 so I'm less familiar with how to write proper type hints before the changes introduced in that version. I'm at a conference right now but I will try to dive in after this week and test against 3.7.

I'm not a maintainer of this package. But I'd you'd like I can help out and make a PR targeting your branch.

noxdafox commented 5 days ago

Hi @emiliadecaudin, thanks for your contribution!

I second @JoaquimEsteves feedback, although Python 3.8 is going EOL in October, it would be great to still support older versions as this module is used by quite few projects.

This does not mean we have to backport this feature in previous versions. We simply need to support the case in which an older Python interpreter is used.

As type hints are a non functional feature, we can definitely skip support for older Python versions. Just make this functionality optional. :wink: