When unpacking an iterable into a tuple as part of an except clause, B013 is triggered even though the unpacking can cause the tuple to contain multiple exceptions.
Example:
exceptions = [ConnectionError, PermissionError]
try:
_foo()
except (*exceptions,): # B013: A length-one tuple literal is redundant in exception handlers
pass
Repro on ruff playground: https://play.ruff.rs/6b9daf6a-96fb-48ab-9be6-db236f86ec21
Ruff version: 0.5.4
As a workaround for my specific use case, the tuple constructor accepts an iterable, making the following possible:
try:
_foo()
except tuple(exceptions):
pass
When unpacking an iterable into a tuple as part of an except clause,
B013is triggered even though the unpacking can cause the tuple to contain multiple exceptions.Example:
Repro on ruff playground: https://play.ruff.rs/6b9daf6a-96fb-48ab-9be6-db236f86ec21
Ruff version: 0.5.4
As a workaround for my specific use case, the
tupleconstructor accepts an iterable, making the following possible: