diff options
author | Simon Heisterkamp <simon@heisterkamp.dk> | 2022-12-01 10:42:44 +0000 |
---|---|---|
committer | Andi Albrecht <albrecht.andi@gmail.com> | 2023-01-02 08:54:47 +0100 |
commit | 4efdc036623e1586206d7132abf95696953deb9a (patch) | |
tree | 31f1b14c039c9a9127b3bbcce94da7abe1508661 | |
parent | e0d3928ba69d73ba874ca03ec4395e94cf1ab293 (diff) | |
download | sqlparse-4efdc036623e1586206d7132abf95696953deb9a.tar.gz |
flake8
-rw-r--r-- | sqlparse/lexer.py | 5 | ||||
-rw-r--r-- | tests/test_keywords.py | 1 | ||||
-rw-r--r-- | tests/test_parse.py | 19 |
3 files changed, 19 insertions, 6 deletions
diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py index 50799df..657177c 100644 --- a/sqlparse/lexer.py +++ b/sqlparse/lexer.py @@ -57,7 +57,10 @@ class Lexer(metaclass=_LexerSingletonMetaclass): def set_SQL_REGEX(self, SQL_REGEX): """Set the list of regex that will parse the SQL.""" FLAGS = re.IGNORECASE | re.UNICODE - self._SQL_REGEX = [(re.compile(rx, FLAGS).match, tt) for rx, tt in SQL_REGEX] + self._SQL_REGEX = [ + (re.compile(rx, FLAGS).match, tt) + for rx, tt in SQL_REGEX + ] def add_keywords(self, keywords): """Add keyword dictionaries. Keywords are looked up in the same order diff --git a/tests/test_keywords.py b/tests/test_keywords.py index a3b1b38..2eddccc 100644 --- a/tests/test_keywords.py +++ b/tests/test_keywords.py @@ -1,7 +1,6 @@ import pytest from sqlparse import tokens -from sqlparse.keywords import SQL_REGEX from sqlparse.lexer import Lexer diff --git a/tests/test_parse.py b/tests/test_parse.py index 017f93a..33e8541 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -491,12 +491,15 @@ def test_parenthesis(): T.Newline, T.Punctuation] + def test_configurable_keywords(): sql = """select * from foo BACON SPAM EGGS;""" tokens = sqlparse.parse(sql)[0] assert list( - (t.ttype, t.value) for t in tokens if t.ttype not in sqlparse.tokens.Whitespace + (t.ttype, t.value) + for t in tokens + if t.ttype not in sqlparse.tokens.Whitespace ) == [ (sqlparse.tokens.Keyword.DML, "select"), (sqlparse.tokens.Wildcard, "*"), @@ -520,7 +523,9 @@ def test_configurable_keywords(): Lexer().default_initialization() assert list( - (t.ttype, t.value) for t in tokens if t.ttype not in sqlparse.tokens.Whitespace + (t.ttype, t.value) + for t in tokens + if t.ttype not in sqlparse.tokens.Whitespace ) == [ (sqlparse.tokens.Keyword.DML, "select"), (sqlparse.tokens.Wildcard, "*"), @@ -539,7 +544,11 @@ def test_configurable_regex(): my_regex = (r"ZORDER\s+BY\b", sqlparse.tokens.Keyword) - lex.set_SQL_REGEX(keywords.SQL_REGEX[:38] + [my_regex] + keywords.SQL_REGEX[38:]) + lex.set_SQL_REGEX( + keywords.SQL_REGEX[:38] + + [my_regex] + + keywords.SQL_REGEX[38:] + ) lex.add_keywords(keywords.KEYWORDS_COMMON) lex.add_keywords(keywords.KEYWORDS_ORACLE) lex.add_keywords(keywords.KEYWORDS_PLPGSQL) @@ -553,5 +562,7 @@ def test_configurable_regex(): Lexer().default_initialization() assert list( - (t.ttype, t.value) for t in tokens if t.ttype not in sqlparse.tokens.Whitespace + (t.ttype, t.value) + for t in tokens + if t.ttype not in sqlparse.tokens.Whitespace )[4] == (sqlparse.tokens.Keyword, "zorder by") |