Skip to content

Commit b9d8037

Browse files
committed
optimize
1 parent b7b82c3 commit b9d8037

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/runtime_docstrings/_parser.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,25 @@
1414
def _parse_docstrings(node: ast.ClassDef) -> dict[str, str]:
1515
docs: dict[str, str] = {}
1616
body = node.body
17-
for index in range(len(body) - 1):
18-
match body[index]:
17+
end = len(body) - 1
18+
index = 0
19+
while index < end:
20+
stmt = body[index]
21+
index += 1
22+
match stmt:
1923
case ast.AnnAssign(target=ast.Name(id=name)):
2024
pass
2125
case ast.Assign(targets=[ast.Name(id=name)]):
2226
pass
2327
case _:
2428
continue
2529

26-
match body[index + 1]:
30+
match body[index]:
2731
case ast.Expr(value=ast.Constant(value=doc_str)) if isinstance(
2832
doc_str, str
2933
):
3034
docs[name] = inspect.cleandoc(doc_str)
35+
index += 1
3136
return docs
3237

3338

0 commit comments

Comments
 (0)