mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-31 08:40:19 +08:00
fix: move _torch_available before usage and use importlib.util.find_spec
Fixes ruff F821 (undefined name) and F401 (unused import) errors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
f4623c0e1b
commit
17eed38750
@ -1,8 +1,15 @@
|
|||||||
"""Tests for external cache provider API."""
|
"""Tests for external cache provider API."""
|
||||||
|
|
||||||
|
import importlib.util
|
||||||
import pytest
|
import pytest
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
|
def _torch_available() -> bool:
|
||||||
|
"""Check if PyTorch is available."""
|
||||||
|
return importlib.util.find_spec("torch") is not None
|
||||||
|
|
||||||
|
|
||||||
from comfy_execution.cache_provider import (
|
from comfy_execution.cache_provider import (
|
||||||
CacheProvider,
|
CacheProvider,
|
||||||
CacheContext,
|
CacheContext,
|
||||||
@ -347,12 +354,3 @@ class MockCacheProvider(CacheProvider):
|
|||||||
|
|
||||||
def on_store(self, context: CacheContext, value: CacheValue) -> None:
|
def on_store(self, context: CacheContext, value: CacheValue) -> None:
|
||||||
self.stores.append((context, value))
|
self.stores.append((context, value))
|
||||||
|
|
||||||
|
|
||||||
def _torch_available() -> bool:
|
|
||||||
"""Check if PyTorch is available."""
|
|
||||||
try:
|
|
||||||
import torch
|
|
||||||
return True
|
|
||||||
except ImportError:
|
|
||||||
return False
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user