Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting type_argument from function annotation #136

Closed
notpushkin opened this issue Jan 26, 2021 · 1 comment
Closed

Getting type_argument from function annotation #136

notpushkin opened this issue Jan 26, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@notpushkin
Copy link

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?

@sobolevn
Copy link
Member

I would love to!

@sobolevn sobolevn added the enhancement New feature or request label Feb 16, 2021
sobolevn added a commit that referenced this issue May 12, 2021
sobolevn added a commit that referenced this issue May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants