From d77bd0e4855e0476350780889f74db2ff9e20eac Mon Sep 17 00:00:00 2001 From: Ankush Gola Date: Tue, 10 Dec 2024 14:37:45 -0800 Subject: [PATCH] remove blanket try/except --- python/langsmith/evaluation/_runner.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/python/langsmith/evaluation/_runner.py b/python/langsmith/evaluation/_runner.py index aea7a86cf..ea206b098 100644 --- a/python/langsmith/evaluation/_runner.py +++ b/python/langsmith/evaluation/_runner.py @@ -1929,17 +1929,14 @@ def _evaluators_include_attachments( return False def evaluator_has_attachments(evaluator: Any) -> bool: - try: - sig = inspect.signature(evaluator) - params = list(sig.parameters.values()) - positional_params = [ - p - for p in params - if p.kind in (p.POSITIONAL_ONLY, p.POSITIONAL_OR_KEYWORD) - ] - return any(p.name == "attachments" for p in positional_params) - except Exception: + if not callable(evaluator): return False + sig = inspect.signature(evaluator) + params = list(sig.parameters.values()) + positional_params = [ + p for p in params if p.kind in (p.POSITIONAL_ONLY, p.POSITIONAL_OR_KEYWORD) + ] + return any(p.name == "attachments" for p in positional_params) return any(evaluator_has_attachments(e) for e in evaluators)