From e1c28d2c3f3bb327752a05ea1d08b1fe89685e8c Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 16 Feb 2015 10:07:41 +0100 Subject: [PATCH] variables starting with 'class' and 'def' should not slow down the parser, changed the check to 'class ' and 'def '. --- jedi/parser/fast.py | 2 +- test/test_parser/test_fast_parser.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/jedi/parser/fast.py b/jedi/parser/fast.py index 4ca594d3..1434171a 100644 --- a/jedi/parser/fast.py +++ b/jedi/parser/fast.py @@ -221,7 +221,7 @@ class ParserNode(object): class FastParser(use_metaclass(CachedFastParser)): - _keyword_re = re.compile('^[ \t]*(def|class|@|%s)' % '|'.join(FLOWS)) + _keyword_re = re.compile('^[ \t]*(def |class |@|%s)' % '|'.join(FLOWS)) def __init__(self, grammar, source, module_path=None): # set values like `pr.Module`. diff --git a/test/test_parser/test_fast_parser.py b/test/test_parser/test_fast_parser.py index f956f1e0..ccfe5e13 100644 --- a/test/test_parser/test_fast_parser.py +++ b/test/test_parser/test_fast_parser.py @@ -163,6 +163,17 @@ def test_for(): check_fp(src, 1) +def test_class_with_class_var(): + src = dedent("""\ + class SuperClass: + class_super = 3 + def __init__(self): + self.foo = 4 + pass + """) + check_fp(src, 3) + + def test_func_with_if(): src = dedent("""\ def recursion(a):