Skip to content

Getting type_argument from function annotation #136

@notpushkin

Description

@notpushkin

Hey @sobolevn!

functools.singledispatch now supports using type annotations instead of passing an argument:

@singledispatch
def fun(arg, verbose=False):
    ...

@fun.register
def _(arg: int, verbose=False):
    ...

The old syntax still works, but in simple cases like here this helps reduce unnecessary repetition and, as a result, the code looks a bit cleaner.

Would you be interesting in accepting a PR implementing similar interface for _TypeClass.instance?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions