-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
The Standard Library module typing introduces many useful types, which is very useful for type hinting. For instance, one can define the type of the elements expected of a list. The code below fails:
from type_valid import type_valid
from typing import List
@type_valid
def foobar(arg: List[float]) -> bool:
return True
my_list = [1.1, 3.2, 7.2]
print(foobar(my_list))
While using a regular list type instead of List[float] doesn't:
from type_valid import type_valid
@type_valid
def foobar(arg: list) -> bool:
return True
my_list = [1.1, 3.2, 7.2]
print(foobar(my_list))
It's worth noting that tools such as mypy support listings.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels