Skip to content

Ability to use Callable type alias when annotating functions #1641

Closed
@neruson

Description

@neruson

If I have a type alias that is a Callable and a function that matches that type alias, it would be nice to annotate the function using just the type alias.

Example:

Validator = Callable[[Any], Optional[str]]

def check_string(val):
    # type: Validator
    ... # check if val is a string, return an error message if it isn't

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions