Skip to content

Commit

Permalink
fix: raise IndexError from __getitem__, not StopIteration
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Feb 22, 2023
1 parent 235f235 commit 7631c8b
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/ape/managers/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,19 +510,22 @@ def __getitem_int(self, index: int) -> ReceiptAPI:
if index < 0:
index += len(self)

return cast(
ReceiptAPI,
next(
self.query_manager.query(
AccountTransactionQuery(
columns=list(ReceiptAPI.__fields__),
account=self.address,
start_nonce=index,
stop_nonce=index,
try:
return cast(
ReceiptAPI,
next(
self.query_manager.query(
AccountTransactionQuery(
columns=list(ReceiptAPI.__fields__),
account=self.address,
start_nonce=index,
stop_nonce=index,
)
)
)
),
)
),
)
except StopIteration as e:
raise IndexError(f"index {index} out of range") from e

@__getitem__.register
def __getitem_slice(self, indices: slice) -> List[ReceiptAPI]:
Expand Down

0 comments on commit 7631c8b

Please sign in to comment.