Upstream andialbrecht/sqlparse state of the touched files before f47b549867

This commit is contained in:
upstream committed 2026-09-02 12:14:20 +02:00
1 parent f0a09a4a1b
commit 40155f3cf6
4 files changed
+9 -58

No files matched your search

+6 -20
View File
@@ -188,8 +188,7 @@ def group_period(tlist):
return (pidx, nidx) if valid_next else (pidx, tidx)
_group(tlist, sql.Identifier, match, valid_prev, valid_next, post,
skip_comments=True)
_group(tlist, sql.Identifier, match, valid_prev, valid_next, post)
def group_as(tlist):
@@ -206,8 +205,7 @@ def group_as(tlist):
def post(tlist, pidx, tidx, nidx):
return pidx, nidx
_group(tlist, sql.Identifier, match, valid_prev, valid_next, post,
skip_comments=True)
_group(tlist, sql.Identifier, match, valid_prev, valid_next, post)
def group_assignment(tlist):
@@ -483,16 +481,9 @@ def _group(tlist, cls, match,
post=None,
extend=True,
recurse=True,
depth=0,
skip_comments=False
depth=0
):
"""Groups together tokens that are joined by a middle token. i.e. x < y
When *skip_comments* is ``True`` comments interleaved between the joined
tokens are ignored while looking for the previous and next token, so
e.g. ``a -- c\\n . -- c\\n b`` still groups into a single identifier
(issue712). The comments themselves stay inside the resulting group.
"""
"""Groups together tokens that are joined by a middle token. i.e. x < y"""
if MAX_GROUPING_DEPTH is not None and depth > MAX_GROUPING_DEPTH:
raise SQLParseError(
f"Maximum grouping depth exceeded ({MAX_GROUPING_DEPTH})."
@@ -519,10 +510,10 @@ def _group(tlist, cls, match,
if recurse and token.is_group and not isinstance(token, cls):
_group(token, cls, match, valid_prev, valid_next,
post, extend, True, depth + 1, skip_comments)
post, extend, True, depth + 1)
if match(token):
nidx, next_ = tlist.token_next(tidx, skip_cm=skip_comments)
nidx, next_ = tlist.token_next(tidx)
if prev_ and valid_prev(prev_) and valid_next(next_):
from_idx, to_idx = post(tlist, pidx, tidx, nidx)
grp = tlist.group_tokens(cls, from_idx, to_idx, extend=extend)
@@ -531,9 +522,4 @@ def _group(tlist, cls, match,
pidx, prev_ = from_idx, grp
continue
if skip_comments and imt(token, t=T.Comment, i=sql.Comment):
# Keep prev_ pointing at the real previous token so an interleaved
# comment does not defeat valid_prev (issue712).
continue
pidx, prev_ = tidx, token