| 1 |
from functools import singledispatchmethod |
| 2 |
|
| 3 |
|
| 4 |
class Foo: |
| 5 |
"""docstring""" |
| 6 |
|
| 7 |
@singledispatchmethod |
| 8 |
def meth(self, arg, kwarg=None): |
| 9 |
"""A method for general use.""" |
| 10 |
pass |
| 11 |
|
| 12 |
@meth.register(int) |
| 13 |
@meth.register(float) |
| 14 |
def _meth_int(self, arg, kwarg=None): |
| 15 |
"""A method for int.""" |
| 16 |
pass |
| 17 |
|
| 18 |
@meth.register(str) |
| 19 |
def _meth_str(self, arg, kwarg=None): |
| 20 |
"""A method for str.""" |
| 21 |
pass |
| 22 |
|
| 23 |
@meth.register |
| 24 |
def _meth_dict(self, arg: dict, kwarg=None): |
| 25 |
"""A method for dict.""" |
| 26 |
# This function tests for specifying type through annotations |
| 27 |
pass |