Skip to content

support for typing module types #1

@gilbertohasnofb

Description

@gilbertohasnofb

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions