8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Right now it is impossible to write a code like this one:
from classes import typeclass from typing import List @typeclass def some(instance) -> int: ... @some.instance(List[int]) def _some_list_int(instance: List[int]) -> int: ...
Because, you cannot check that some variable has type List[int] in runtime.
List[int]
Maybe we can use runtime typecheckers? Like: https://github.com/erezsh/runtype
Related #8
The text was updated successfully, but these errors were encountered:
Or https://github.com/beartype/beartype
Sorry, something went wrong.
My current design:
from typing import List, TYPE_CHECKING if not TYPE_CHECKING: reveal_type = prin 870F t from phantom import Phantom from phantom.predicates import collection, generic class ListOfInt( List[int], Phantom, predicate=collection.every(generic.of_type(int)), ): ... from classes import typeclass @typeclass def sum_all(instance) -> int: ... @sum_all.instance(List[int], delegate=ListOfInt) def _sum_list_of_int(instance: List[int]) -> int: return sum(x for x in instance) l = [1, 2, 3] reveal_type(sum_all(l))
It both typechecks (I need to fix my plugin, though) and works in runtime.
delegate
Successfully merging a pull request may close this issue.
Right now it is impossible to write a code like this one:
Because, you cannot check that some variable has type
List[int]
in runtime.Maybe we can use runtime typecheckers? Like: https://github.com/erezsh/runtype
Related #8
The text was updated successfully, but these errors were encountered: