Fix ruff SIM105: use contextlib.suppress

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
strawgate 2026-05-12 23:00:15 -05:00
commit 8100fc713f

View file

@ -7,6 +7,7 @@ extraction logic, and callable unwrapping across the codebase.
from __future__ import annotations
import contextlib
import functools
import inspect
from collections.abc import Callable
@ -77,10 +78,8 @@ def prepare_callable(fn: Callable[..., Any]) -> Callable[..., Any]:
except AttributeError:
pass
else:
try:
with contextlib.suppress(AttributeError):
setattr(fn, attr, val)
except AttributeError:
pass
# Callable classes (not routines, not partials) → unwrap to __call__
if not inspect.isroutine(fn) and not isinstance(fn, functools.partial):