-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Description
Using ruff 0.0.286 the following:
bar = (n for n in ())
try:
foo = list(bar)[0]
except IndexError:
pass
else:
print(foo)is rewritten to:
bar = (n for n in ())
try:
foo = next(iter(bar))
except IndexError:
pass
else:
print(foo)The rewritten code is now prone to raising an uncaught StopIteration error.
Same thing goes for the rewrite of:
import contextlib
bar = (n for n in ())
with contextlib.suppress(IndexError):
foo = list(bar)[0]
print(foo)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels