From e05ce5ae3124985e1d22797c7cb751971d6b67cd Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 28 Mar 2018 09:51:37 +0200 Subject: [PATCH] Revert "A small improvement in checks" The problem with this commit is that it probably makes some checks slower. It's still slightly more beautiful, but we leave it for now. This reverts commit 25e4ea9c24add0579aff0aeed6474d58299f1919. --- parso/python/tokenize.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/parso/python/tokenize.py b/parso/python/tokenize.py index 2820669..8537884 100644 --- a/parso/python/tokenize.py +++ b/parso/python/tokenize.py @@ -59,6 +59,10 @@ def group(*choices, **kwargs): return start + '|'.join(choices) + ')' +def any(*choices): + return group(*choices) + '*' + + def maybe(*choices): return group(*choices) + '?' @@ -353,7 +357,9 @@ def tokenize_lines(lines, version_info, start_pos=(1, 0)): contstr = line[start:] contline = line break - elif any(token.startswith(s) for s in single_quoted): + elif initial in single_quoted or \ + token[:2] in single_quoted or \ + token[:3] in single_quoted: if token[-1] == '\n': # continued string contstr_start = lnum, start endprog = (endpats.get(initial) or endpats.get(token[1])