Skip to content

Commit

Permalink
mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Nov 10, 2024
1 parent 607d962 commit 43d2cef
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions eth_retry/eth_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from json import JSONDecodeError
from random import randrange
from time import sleep
from typing import Awaitable, Callable, TypeVar, Union, overload
from typing import Awaitable, Callable, Optional, TypeVar, Union, overload

import requests

Expand Down Expand Up @@ -163,9 +163,10 @@ def should_retry(e: Exception, failures: int) -> bool:
_aio_files = ["asyncio/events.py" "asyncio/base_events.py"]


def _get_caller_details_from_stack() -> str:
def _get_caller_details_from_stack() -> Optional[str]:
for frame in inspect.stack()[2:]:
if all(filename not in frame.filename for filename in _aio_files):
details = f"{frame.filename} line {frame.lineno}"
context = frame.code_context
return details if context is None else f"{details} {[context[0].strip()]}"
return None

0 comments on commit 43d2cef

Please sign in to comment.