dry-python/classes

Getting type_argument from function annotation

Closed this issue · 1 comments

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?

I would love to!