mirror of
https://github.com/deepseek-ai/DeepInfer.git
synced 2026-10-29 23:37:28 +08:00
style: resolve Ruff UP038 lint violations
This commit is contained in:
parent
774ce244b8
commit
99dff9a825
@ -645,7 +645,7 @@ class LLMEngine:
|
||||
>>> # abort the request
|
||||
>>> engine.abort_request(request_id)
|
||||
"""
|
||||
assert isinstance(request_id, (str, dict, set, list, tuple)), f"invalid request_id type: {type(request_id)}"
|
||||
assert isinstance(request_id, str | dict | set | list | tuple), f"invalid request_id type: {type(request_id)}"
|
||||
request_id = [request_id] if isinstance(request_id, str) else list(request_id)
|
||||
|
||||
seqs = self.scheduler.abort_sequence(request_id)
|
||||
|
||||
@ -61,7 +61,7 @@ def _resolve_images(row: dict[str, Any]) -> tuple[tuple[str, ...], tuple[tuple[i
|
||||
|
||||
raw = row.get("image")
|
||||
if not urls and raw:
|
||||
if isinstance(raw, (bytes, bytearray)):
|
||||
if isinstance(raw, bytes | bytearray):
|
||||
urls = [_write_cached_image(row, bytes(raw), 0)]
|
||||
else:
|
||||
text = str(raw).strip()
|
||||
@ -102,7 +102,7 @@ def _has_image(row: dict[str, Any]) -> bool:
|
||||
img = row.get("image")
|
||||
if img is None:
|
||||
return False
|
||||
if isinstance(img, (bytes, bytearray)):
|
||||
if isinstance(img, bytes | bytearray):
|
||||
return len(img) > 0
|
||||
return bool(str(img).strip())
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ def _normalize_trace_events(trace: dict) -> None:
|
||||
"""replace all time to Decimal"""
|
||||
for event in trace.get("traceEvents") or []:
|
||||
for key in ("ts", "dur"):
|
||||
if key in event and not isinstance(event[key], Decimal) and isinstance(event[key], (str, float)):
|
||||
if key in event and not isinstance(event[key], Decimal) and isinstance(event[key], str | float):
|
||||
event[f"_was_str_{key}"] = isinstance(event[key], str)
|
||||
event[key] = _to_decimal(event[key])
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user