Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions sqlspec/utils/sync_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,7 @@ async def get_next(iterable: Any, default: Any = NO_VALUE, *args: Any) -> Any:

Returns:
The next value of the iterable.

Raises:
StopAsyncIteration: The iterable given is not async.
"""
has_default = bool(not isinstance(default, NoValue))
try:
return await iterable.__anext__()

except StopAsyncIteration as exc:
if has_default:
return default

raise StopAsyncIteration from exc
if isinstance(default, NoValue):
return await anext(iterable)
return await anext(iterable, default)