Skip to content

Commit 79ae23e

Browse files
committed
Use generator functions where needed
1 parent 0ba7b27 commit 79ae23e

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

jsonschema_lexer/_lexer.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,14 @@ def _find_rightmost_token_index(
6868
syntax_stack: list[tuple[int, str]],
6969
token: str | None,
7070
):
71-
for i in range(len(syntax_stack) - 1, -1, -1):
72-
if syntax_stack[i][1] == token:
73-
return i
74-
return None
71+
return next((i for i, (_, t) in reversed(list(enumerate(syntax_stack))) if t == token), None)
7572

7673
def _find_key_value_from_json(
7774
self,
7875
tokens: list[tuple[int, Any, str]],
7976
index: int,
8077
):
81-
for i in range(index, len(tokens), 1):
82-
if tokens[i][1] is Token.String.Double:
83-
return tokens[i][2]
84-
return None
78+
return next((t[2] for t in tokens[index:] if t[1] is Token.String.Double), None)
8579

8680
def _get_nearest_valid_dialect(
8781
self,

0 commit comments

Comments
 (0)