-
Notifications
You must be signed in to change notification settings - Fork 3
Doesn't support hinting #34
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
Comments
Type hinting was introduced in python 3.5 and continues to evolve. Due to our goal of supporting as many python versions as possible, type hinting has taken a backseat. We will continue to watch for a way to backport type hints of generics through all supported versions of python and reevaluate. That being said, this is open source and we are very open to contribution, so feel free to open a PR. |
How can i implement it on python>=3.5 and that it will still be backward compatible? |
@matanbanin Yes that is my struggle too! If you look at the PR I made above I tried adding them in a way that works for all versions of Python but the hinting doesnt seem 100% correct. Feel free to pull that branch as a initial starting point! |
I can't create a new branch, so i'll post my code here optional.py It seems to work on my python, is this code compatible on older versions? from typing import Any, TypeVar, Generic from optional.abstract_optional import AbstractOptional T = TypeVar('T') class Optional(Generic[T]):
int = Optional.of(1) |
Unfortunately, what you did above is not completely backwards compatible. Pre 3.5 versions of python only accept the comment style of hints so your line: def of(cls, thing: T = None) -> AbstractOptional[T]: would cause problems due to both the I made a branch called |
from typing import Any, TypeVar, Generic from optional.abstract_optional import AbstractOptional T = TypeVar('T') class Optional(Generic[T]):
int = Optional.of(1) And this? |
? |
@dpassen this is solved by new version right? |
lgtm closing |
Which is pretty crucial on a wrap of an object, i couldn't use it that way...
The text was updated successfully, but these errors were encountered: