Skip to content

Commit

Permalink
slob.py: _resolve_aliases: minimize try..except StopIteration block
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Mar 16, 2024
1 parent 2f582c4 commit cb815b1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pyglossary/slob.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,15 +1279,16 @@ def read_key_frag(item: "Blob", default_fragment: str) -> "tuple[str, str]":
while count <= self.max_redirects:
# is target key itself a redirect?
try:
orig_to_key = to_key
to_key, fragment = read_key_frag(
cast(Blob, next(aliases[to_key])),
fragment,
)
count += 1
keys.add(orig_to_key)
alias_item: Blob = next(aliases[to_key])
except StopIteration:
break
orig_to_key = to_key
to_key, fragment = read_key_frag(
alias_item,
fragment,
)
count += 1
keys.add(orig_to_key)
if count > self.max_redirects:
self._fire_event("too_many_redirects", from_key)
target_ref: Ref
Expand Down

0 comments on commit cb815b1

Please sign in to comment.