Skip to content

Commit af37d16

Browse files
committed
Fix flake8 styling
1 parent 5d77add commit af37d16

5 files changed

Lines changed: 8 additions & 10 deletions

File tree

sqlparse/engine/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def run(self, sql, encoding=None):
4343
for filter_ in self.preprocess:
4444
stream = filter_.process(self, stream)
4545

46-
if self.stmtprocess or self.postprocess or self.split_statements \
47-
or self._grouping:
46+
if (self.stmtprocess or self.postprocess or
47+
self.split_statements or self._grouping):
4848
splitter = StatementFilter()
4949
stream = splitter.process(self, stream)
5050

sqlparse/engine/grouping.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@ def _group_left_right(tlist, m, cls,
2727

2828
if valid_left(left) and valid_right(right):
2929
if semicolon:
30+
# only overwrite if a semicolon present.
3031
sright = tlist.token_next_by(m=M_SEMICOLON, idx=right)
31-
right = sright or right # only overwrite if a semicolon present.
32+
right = sright or right
3233
tokens = tlist.tokens_between(left, right)
3334
token = tlist.group_tokens(cls, tokens, extend=True)
3435
token = tlist.token_next_by(m=m, idx=token)
3536

3637

3738
def _group_matching(tlist, cls):
38-
"""Groups Tokens that have beginning and end. ie. parenthesis, brackets.."""
39+
"""Groups Tokens that have beginning and end."""
3940
idx = 1 if imt(tlist, i=cls) else 0
4041

4142
token = tlist.token_next_by(m=cls.M_OPEN, idx=idx)

sqlparse/sql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def token_next(self, idx, skip_ws=True):
316316

317317
def token_index(self, token, start=0):
318318
"""Return list index of token."""
319-
start = self.token_index(start) if not isinstance(start, int) else start
319+
start = start if isinstance(start, int) else self.token_index(start)
320320
return start + self.tokens[start:].index(token)
321321

322322
def tokens_between(self, start, end, include_end=True):

tests/test_functions.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
from sqlparse.filters import IncludeStatement, Tokens2Unicode
99
from sqlparse.lexer import tokenize
1010

11-
import sys
12-
sys.path.insert(0, '..')
13-
1411
from sqlparse.filters import compact
1512
from sqlparse.functions import getcolumns, getlimit, IsType
1613
from tests.utils import FILES_DIR

tests/test_regressions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import sqlparse
88
from sqlparse import sql
99
from sqlparse import tokens as T
10-
from sqlparse.compat import u
1110

1211

1312
class RegressionTests(TestCaseBase):
@@ -296,7 +295,8 @@ def test_issue213_leadingws():
296295
def test_issue227_gettype_cte():
297296
select_stmt = sqlparse.parse('SELECT 1, 2, 3 FROM foo;')
298297
assert select_stmt[0].get_type() == 'SELECT'
299-
with_stmt = sqlparse.parse('WITH foo AS (SELECT 1, 2, 3) SELECT * FROM foo;')
298+
with_stmt = sqlparse.parse('WITH foo AS (SELECT 1, 2, 3)'
299+
'SELECT * FROM foo;')
300300
assert with_stmt[0].get_type() == 'SELECT'
301301
with2_stmt = sqlparse.parse('''
302302
WITH foo AS (SELECT 1 AS abc, 2 AS def),

0 commit comments

Comments
 (0)