From 11b7f9f7f690f5a2dc6f50e080302ea88711e6ef Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Fri, 16 May 2014 15:33:21 +0200 Subject: [PATCH] decorators should also be included in the static analysis --- jedi/evaluate/analysis.py | 7 +++++++ test/static_analysis/attribute_error.py | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/jedi/evaluate/analysis.py b/jedi/evaluate/analysis.py index b43a92b3..57b7f75d 100644 --- a/jedi/evaluate/analysis.py +++ b/jedi/evaluate/analysis.py @@ -138,4 +138,11 @@ def get_module_statements(module): imports |= set(scope.imports) stmts |= add_stmts(scope.statements) stmts |= add_stmts(r for r in scope.returns if r is not None) + + try: + decorators = scope.decorators + except AttributeError: + pass + else: + stmts |= add_stmts(decorators) return stmts, imports diff --git a/test/static_analysis/attribute_error.py b/test/static_analysis/attribute_error.py index b90271a1..e6b50b96 100644 --- a/test/static_analysis/attribute_error.py +++ b/test/static_analysis/attribute_error.py @@ -75,3 +75,12 @@ return_one(''.undefined_attribute) [undefined for r in [1, 2]] [r for r in [1, 2]] + +# ----------------- +# decorators +# ----------------- + +#! 1 name-error +@undefined_decorator +def func(): + return 1