diff --git a/src/ssort/_parsing.py b/src/ssort/_parsing.py index 7afc3e9..24d3e5f 100644 --- a/src/ssort/_parsing.py +++ b/src/ssort/_parsing.py @@ -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 == ":"