Skip to content

Commit 6a7eb24

Browse files
Andreas AlbrechtAndreas Albrecht
authored andcommitted
Code cleanup.
1 parent bc84fdc commit 6a7eb24

File tree

6 files changed

+19
-17
lines changed

6 files changed

+19
-17
lines changed

sqlparse/engine/grouping.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ def group_identifier_list(tlist):
225225
m_role = T.Keyword, ('null', 'role')
226226
sqlcls = (sql.Function, sql.Case, sql.Identifier, sql.Comparison,
227227
sql.IdentifierList, sql.Operation)
228-
ttypes = (T_NUMERICAL + T_STRING + T_NAME +
229-
(T.Keyword, T.Comment, T.Wildcard))
228+
ttypes = (T_NUMERICAL + T_STRING + T_NAME
229+
+ (T.Keyword, T.Comment, T.Wildcard))
230230

231231
def match(token):
232232
return token.match(T.Punctuation, ',')

sqlparse/engine/statement_splitter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def _change_splitlevel(self, ttype, value):
6565
self._begin_depth = max(0, self._begin_depth - 1)
6666
return -1
6767

68-
if (unified in ('IF', 'FOR', 'WHILE') and
69-
self._is_create and self._begin_depth > 0):
68+
if (unified in ('IF', 'FOR', 'WHILE')
69+
and self._is_create and self._begin_depth > 0):
7070
return 1
7171

7272
if unified in ('END IF', 'END FOR', 'END WHILE'):

sqlparse/filters/others.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def get_next_comment():
2323
nidx, next_ = tlist.token_next(tidx, skip_ws=False)
2424
# Replace by whitespace if prev and next exist and if they're not
2525
# whitespaces. This doesn't apply if prev or next is a parenthesis.
26-
if (prev_ is None or next_ is None or
27-
prev_.is_whitespace or prev_.match(T.Punctuation, '(') or
28-
next_.is_whitespace or next_.match(T.Punctuation, ')')):
26+
if (prev_ is None or next_ is None
27+
or prev_.is_whitespace or prev_.match(T.Punctuation, '(')
28+
or next_.is_whitespace or next_.match(T.Punctuation, ')')):
2929
tlist.tokens.remove(token)
3030
else:
3131
tlist.tokens[tidx] = sql.Token(T.Whitespace, ' ')

sqlparse/keywords.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
def is_keyword(value):
1515
val = value.upper()
16-
return (KEYWORDS_COMMON.get(val) or
17-
KEYWORDS_ORACLE.get(val) or
18-
KEYWORDS_PLPGSQL.get(val) or
19-
KEYWORDS.get(val, tokens.Name)), value
16+
return (KEYWORDS_COMMON.get(val)
17+
or KEYWORDS_ORACLE.get(val)
18+
or KEYWORDS_PLPGSQL.get(val)
19+
or KEYWORDS.get(val, tokens.Name)), value
2020

2121

2222
SQL_REGEX = {

sqlparse/sql.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,9 @@ def token_first(self, skip_ws=True, skip_cm=False):
239239
ignored too.
240240
"""
241241
# this on is inconsistent, using Comment instead of T.Comment...
242-
funcs = lambda tk: not ((skip_ws and tk.is_whitespace) or
243-
(skip_cm and imt(tk, t=T.Comment, i=Comment)))
242+
funcs = lambda tk: not ((skip_ws and tk.is_whitespace)
243+
or (skip_cm and imt(tk,
244+
t=T.Comment, i=Comment)))
244245
return self._token_matching(funcs)[1]
245246

246247
def token_next_by(self, i=None, m=None, t=None, idx=-1, end=None):
@@ -276,8 +277,9 @@ def token_next(self, idx, skip_ws=True, skip_cm=False, _reverse=False):
276277
if idx is None:
277278
return None, None
278279
idx += 1 # alot of code usage current pre-compensates for this
279-
funcs = lambda tk: not ((skip_ws and tk.is_whitespace) or
280-
(skip_cm and imt(tk, t=T.Comment, i=Comment)))
280+
funcs = lambda tk: not ((skip_ws and tk.is_whitespace)
281+
or (skip_cm and imt(tk,
282+
t=T.Comment, i=Comment)))
281283
return self._token_matching(funcs, idx, reverse=_reverse)
282284

283285
def token_index(self, token, start=0):

tests/test_format.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ def test_notransform_of_quoted_crlf(self):
106106
assert f(s1) == "SELECT some_column LIKE 'value\r'"
107107
assert f(s2) == "SELECT some_column LIKE 'value\r'\nWHERE id = 1\n"
108108
assert f(s3) == "SELECT some_column LIKE 'value\\'\r' WHERE id = 1\n"
109-
assert (f(s4) ==
110-
"SELECT some_column LIKE 'value\\\\\\'\r' WHERE id = 1\n")
109+
assert (f(s4)
110+
== "SELECT some_column LIKE 'value\\\\\\'\r' WHERE id = 1\n")
111111

112112

113113
class TestFormatReindentAligned(object):

0 commit comments

Comments
 (0)