Skip to content

Commit

Permalink
Revert refactoring of _optional_nested_brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
ericbn committed Apr 18, 2024
1 parent ac899c9 commit 20b3f63
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/ssort/_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,24 @@ def split_class(statement):
assert token.type == NAME

token = next(tokens)

def _optional_nested_brackets(open: str, close: str):
nonlocal token
if token.string == open:
if token.string == "[":
token = next(tokens)
depth = 1
while depth:
if token.string == "[":
depth += 1
if token.string == "]":
depth -= 1
token = next(tokens)
if token.string == "(":
token = next(tokens)
depth = 1
while depth:
if token.string == "(":
depth += 1
if token.string == ")":
depth -= 1
token = next(tokens)
depth = 1
while depth:
if token.string == open:
depth += 1
if token.string == close:
depth -= 1
token = next(tokens)

_optional_nested_brackets("[", "]")
_optional_nested_brackets("(", ")")

assert token.string == ":"

Expand Down

0 comments on commit 20b3f63

Please sign in to comment.