From e355ab201e7d3948922eb7a6df293ab615aabb55 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 1 Jul 2015 14:40:57 +0200 Subject: [PATCH] Tests and implementation for type on lambda and function objects. --- jedi/evaluate/representation.py | 3 +++ test/completion/stdlib.py | 7 +++++-- test/static_analysis/branches.py | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/jedi/evaluate/representation.py b/jedi/evaluate/representation.py index 3cfcaa9b..90a170a1 100644 --- a/jedi/evaluate/representation.py +++ b/jedi/evaluate/representation.py @@ -559,6 +559,9 @@ class Function(use_metaclass(CachedMetaClass, Wrapper)): else: return FunctionExecution(evaluator, self, params).get_return_types() + def py__class__(self, evaluator): + return compiled.magic_function_class + def __getattr__(self, name): return getattr(self.base_func, name) diff --git a/test/completion/stdlib.py b/test/completion/stdlib.py index 9224300d..4a13bc8a 100644 --- a/test/completion/stdlib.py +++ b/test/completion/stdlib.py @@ -35,8 +35,9 @@ next(open('')) #? ['__itemsize__'] tuple.__itemsize__ -# type - +# ----------------- +# type() calls with one parameter +# ----------------- #? int type(1) #? int @@ -53,6 +54,8 @@ def x(): generator = type(x()) #? generator type(x for x in []) +#? type(x) +type(lambda: x) # ----------------- # re diff --git a/test/static_analysis/branches.py b/test/static_analysis/branches.py index 6f26f434..21061d8f 100644 --- a/test/static_analysis/branches.py +++ b/test/static_analysis/branches.py @@ -1,3 +1,7 @@ +# ----------------- +# Simple tests +# ----------------- + import random if random.choice([0, 1]):