Skip to content

Getting type_argument from function annotation #136

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?

Activity

  1. sobolevn commented on Jan 26, 2021

    @sobolevn
    Member

    I would love to!

  2. added a commit that references this issue on May 12, 2021
    90faab9
  3. added a commit that references this issue on May 28, 2021
    2568580
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions