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
This commit is contained in:
HUAHAODIA 2026-09-14 15:09:53 +08:00
parent 29cdcf4880
commit b71eff40f8
2 changed files with 11 additions and 13 deletions

View file

@ -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:

View file

@ -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)