Skip to content

Commit 4efdc03

Browse files
mrmasterplanandialbrecht
authored andcommitted
flake8
1 parent e0d3928 commit 4efdc03

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

sqlparse/lexer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ def clear(self):
5757
def set_SQL_REGEX(self, SQL_REGEX):
5858
"""Set the list of regex that will parse the SQL."""
5959
FLAGS = re.IGNORECASE | re.UNICODE
60-
self._SQL_REGEX = [(re.compile(rx, FLAGS).match, tt) for rx, tt in SQL_REGEX]
60+
self._SQL_REGEX = [
61+
(re.compile(rx, FLAGS).match, tt)
62+
for rx, tt in SQL_REGEX
63+
]
6164

6265
def add_keywords(self, keywords):
6366
"""Add keyword dictionaries. Keywords are looked up in the same order

tests/test_keywords.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22

33
from sqlparse import tokens
4-
from sqlparse.keywords import SQL_REGEX
54
from sqlparse.lexer import Lexer
65

76

tests/test_parse.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,12 +491,15 @@ def test_parenthesis():
491491
T.Newline,
492492
T.Punctuation]
493493

494+
494495
def test_configurable_keywords():
495496
sql = """select * from foo BACON SPAM EGGS;"""
496497
tokens = sqlparse.parse(sql)[0]
497498

498499
assert list(
499-
(t.ttype, t.value) for t in tokens if t.ttype not in sqlparse.tokens.Whitespace
500+
(t.ttype, t.value)
501+
for t in tokens
502+
if t.ttype not in sqlparse.tokens.Whitespace
500503
) == [
501504
(sqlparse.tokens.Keyword.DML, "select"),
502505
(sqlparse.tokens.Wildcard, "*"),
@@ -520,7 +523,9 @@ def test_configurable_keywords():
520523
Lexer().default_initialization()
521524

522525
assert list(
523-
(t.ttype, t.value) for t in tokens if t.ttype not in sqlparse.tokens.Whitespace
526+
(t.ttype, t.value)
527+
for t in tokens
528+
if t.ttype not in sqlparse.tokens.Whitespace
524529
) == [
525530
(sqlparse.tokens.Keyword.DML, "select"),
526531
(sqlparse.tokens.Wildcard, "*"),
@@ -539,7 +544,11 @@ def test_configurable_regex():
539544

540545
my_regex = (r"ZORDER\s+BY\b", sqlparse.tokens.Keyword)
541546

542-
lex.set_SQL_REGEX(keywords.SQL_REGEX[:38] + [my_regex] + keywords.SQL_REGEX[38:])
547+
lex.set_SQL_REGEX(
548+
keywords.SQL_REGEX[:38]
549+
+ [my_regex]
550+
+ keywords.SQL_REGEX[38:]
551+
)
543552
lex.add_keywords(keywords.KEYWORDS_COMMON)
544553
lex.add_keywords(keywords.KEYWORDS_ORACLE)
545554
lex.add_keywords(keywords.KEYWORDS_PLPGSQL)
@@ -553,5 +562,7 @@ def test_configurable_regex():
553562
Lexer().default_initialization()
554563

555564
assert list(
556-
(t.ttype, t.value) for t in tokens if t.ttype not in sqlparse.tokens.Whitespace
565+
(t.ttype, t.value)
566+
for t in tokens
567+
if t.ttype not in sqlparse.tokens.Whitespace
557568
)[4] == (sqlparse.tokens.Keyword, "zorder by")

0 commit comments

Comments
 (0)