diff options
Diffstat (limited to 'pylint/test/functional/singledispatch_functions_py3.py')
| -rw-r--r-- | pylint/test/functional/singledispatch_functions_py3.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/pylint/test/functional/singledispatch_functions_py3.py b/pylint/test/functional/singledispatch_functions_py3.py new file mode 100644 index 000000000..f8b816a4e --- /dev/null +++ b/pylint/test/functional/singledispatch_functions_py3.py @@ -0,0 +1,63 @@ +# pylint: disable=missing-docstring,import-error,unused-import,assignment-from-no-return +from __future__ import print_function +from UNINFERABLE import uninferable_decorator, uninferable_func + +try: + from functools import singledispatch +except ImportError: + from singledispatch import singledispatch + +my_single_dispatch = singledispatch # pylint: disable=invalid-name + + +@singledispatch +def func(arg): + return arg + + +@func.register(str) +def _(arg): + return 42 + + +@func.register(float) +@func.register(int) +def _(arg): + return 42 + + +@my_single_dispatch +def func2(arg): + return arg + + +@func2.register(int) +def _(arg): + return 42 + + +@singledispatch +def with_extra_arg(arg, verbose=False): + if verbose: + print(arg) + return arg + + +@with_extra_arg.register(str) +def _(arg, verbose=False): + return arg[::-1] + + +@uninferable_decorator +def uninferable(arg): + return 2*arg + + +@uninferable.register(str) +def bad_single_dispatch(arg): + return arg + + +@uninferable_func.register(str) +def test(arg): + return arg |
