[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2026-07-27 06:19:43 +00:00
commit 35cd77e6d8
4 changed files with 13 additions and 11 deletions

View file

@ -204,7 +204,11 @@ def _resolve_lora_4bit(mc, load_in_4bit: bool) -> bool:
return load_in_4bit
def _ensure_ssm_kernels(targets: list, resp_queue: Any, local_files_only: bool = False) -> bool:
def _ensure_ssm_kernels(
targets: list,
resp_queue: Any,
local_files_only: bool = False,
) -> bool:
"""Install the SSM kernels the given model(s) lazy-import in from_pretrained; no-op for
non-SSM models, idempotent. Returns True on success; on a fatal mamba-ssm failure sends a
'loaded' failure response and returns False. Call BEFORE importing transformers, which
@ -222,7 +226,6 @@ def _ensure_ssm_kernels(targets: list, resp_queue: Any, local_files_only: bool =
_ssm_status = lambda m: _send_response(resp_queue, {"type": "status", "message": m})
if local_files_only:
import importlib.util
for ssm_target in dict.fromkeys(t for t in targets if t):
try:
needs_mamba = model_is_ssm(ssm_target)

View file

@ -451,11 +451,7 @@ def _repo_non_gguf_model_payload(repo_info) -> _CachedNonGgufPayload:
has_checkpoint = False
def _record_blob(
target: dict[str, tuple[int, float]],
file_obj,
rev_id: str,
file_name: str,
category: str,
target: dict[str, tuple[int, float]], file_obj, rev_id: str, file_name: str, category: str
) -> None:
blob_path = getattr(file_obj, "blob_path", None)
size = int(file_obj.size_on_disk or 0)

View file

@ -65,9 +65,9 @@ def test_overlapping_guards_restore_only_after_last_exit(clean_env):
assert os.environ.get("HF_HUB_OFFLINE") == "1"
assert b.__enter__() is True
a.__exit__(None, None, None)
assert os.environ.get("HF_HUB_OFFLINE") == "1", (
"first exit must not restore while another guard is active"
)
assert (
os.environ.get("HF_HUB_OFFLINE") == "1"
), "first exit must not restore while another guard is active"
b.__exit__(None, None, None)
assert "HF_HUB_OFFLINE" not in os.environ

View file

@ -1193,7 +1193,10 @@ def test_background_picks_mirror_inventory_and_skip_installers():
# command loops (MLX and GPU paths).
bootstrap = worker.split("_bootstrap_offline = contextlib.ExitStack()", 1)[1]
assert bootstrap.count("_bootstrap_offline.close()") == 2
assert "def _ensure_ssm_kernels(targets: list, resp_queue: Any, local_files_only: bool = False) -> bool:" in worker
assert (
"def _ensure_ssm_kernels(targets: list, resp_queue: Any, local_files_only: bool = False) -> bool:"
in worker
)
ssm = worker.split("def _ensure_ssm_kernels", 1)[1]
ssm = ssm.split("def _run_security_gates", 1)[0]
assert "if local_files_only:" in ssm