From b71eff40f8f31c15402c20627bb350ff7caa8282 Mon Sep 17 00:00:00 2001 From: HUAHAODIA Date: Mon, 14 Sep 2026 15:09:53 +0800 Subject: [PATCH] fix lint review feedback - restore the short-circuit in custom_team_metadata_validate: only touch __call__ when the plain coroutine-function check fails, so a raising descriptor on an async function is not newly triggered - inline the noqa reasons per the suppression policy - drop the ruff-strict-budget.json edit: budget ratcheting is reserved for the scheduled automation on the default branch --- .../litellm_core_utils/coroutine_checker.py | 4 +--- .../team_metadata_validation.py | 20 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/litellm/litellm_core_utils/coroutine_checker.py b/litellm/litellm_core_utils/coroutine_checker.py index 9e15b4e870d..7b9a650c66b 100644 --- a/litellm/litellm_core_utils/coroutine_checker.py +++ b/litellm/litellm_core_utils/coroutine_checker.py @@ -36,9 +36,7 @@ class CoroutineChecker: target = callback if not inspect.isfunction(target) and not inspect.ismethod(target): try: - # Value unwrap so iscoroutinefunction can see through functors; - # B004's callable() advice does not apply here. - call_attr: Final = getattr(target, "__call__", None) # noqa: B004 + call_attr: Final = getattr(target, "__call__", None) # noqa: B004 # value unwrap so iscoroutinefunction sees through functors if call_attr is not None: target = call_attr except Exception: diff --git a/litellm/proxy/management_helpers/team_metadata_validation.py b/litellm/proxy/management_helpers/team_metadata_validation.py index 31960442b24..98edb4fb692 100644 --- a/litellm/proxy/management_helpers/team_metadata_validation.py +++ b/litellm/proxy/management_helpers/team_metadata_validation.py @@ -115,16 +115,16 @@ async def run_team_metadata_validation( "error": f"custom_team_metadata_validate is an Enterprise feature. {CommonProxyErrors.not_premium_user.value}" }, ) - # Value unwrap so iscoroutinefunction can see through functors; - # B004's callable() advice does not apply here. - validator_call = getattr(validator, "__call__", None) # noqa: B004 - if not (inspect.iscoroutinefunction(validator) or inspect.iscoroutinefunction(validator_call)): - raise HTTPException( - status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, - detail={ # mutable-ok: HTTPException.detail has no immutable form - "error": "custom_team_metadata_validate must be an async function" - }, - ) + if not inspect.iscoroutinefunction(validator): + # Value unwrap so iscoroutinefunction can see through functors; not a callability test + validator_call = getattr(validator, "__call__", None) # noqa: B004 # value unwrap for functor check + if not inspect.iscoroutinefunction(validator_call): + raise HTTPException( + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, + detail={ # mutable-ok: HTTPException.detail has no immutable form + "error": "custom_team_metadata_validate must be an async function" + }, + ) try: raw_result: Final = await asyncio.wait_for(validator(payload), timeout=timeout_seconds)