summaryrefslogtreecommitdiff
path: root/pylint/test/functional/singledispatch_functions_py3.py
diff options
context:
space:
mode:
authorƁukasz Rogalski <rogalski.91@gmail.com>2016-11-06 11:34:45 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2016-12-04 11:40:37 +0200
commit8bcd4059104329b6fcaa6436fc6d6fa458cca23f (patch)
tree925c08bf897df006227562712f4a9264bd1ad0f5 /pylint/test/functional/singledispatch_functions_py3.py
parente5aa388e01b07718e6549d10a9fff1a957c912b4 (diff)
downloadpylint-git-8bcd4059104329b6fcaa6436fc6d6fa458cca23f.tar.gz
Don't emit unused-argument and function-redefined for singledispatch implementations
Closes #1032 and #1034
Diffstat (limited to 'pylint/test/functional/singledispatch_functions_py3.py')
-rw-r--r--pylint/test/functional/singledispatch_functions_py3.py63
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