Skip to content

Commit

Permalink
fix python 3.9 incompatible type hint syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
telamonian committed Jul 26, 2024
1 parent b78d54e commit d742327
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions comfy_cli/uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import subprocess
import sys
from textwrap import dedent
from typing import Any
from typing import Any, Optional, Union

from comfy_cli.constants import GPU_OPTION

PathLike = os.PathLike[str] | str
PathLike = Union[os.PathLike[str], str]

def _run(cmd: list[str], cwd: PathLike) -> subprocess.CompletedProcess[Any]:
return subprocess.run(
Expand Down Expand Up @@ -55,9 +55,9 @@ def findReqFiles(p: PathLike) -> list[Path]:
def compile(
cwd: PathLike,
reqFiles: list[PathLike],
override: PathLike | None = None,
out: PathLike | None = None,
index_strategy: str | None = "unsafe-best-match",
override: Optional[PathLike] = None,
out: Optional[PathLike] = None,
index_strategy: Optional[str] = "unsafe-best-match",
) -> subprocess.CompletedProcess[Any]:
cmd = [
sys.executable,
Expand Down Expand Up @@ -96,9 +96,9 @@ def compile(
def install(
cwd: PathLike,
reqFile: list[PathLike],
override: PathLike | None = None,
extraUrl: str | None = None,
index_strategy: str | None = "unsafe-best-match",
override: Optional[PathLike] = None,
extraUrl: Optional[str] = None,
index_strategy: Optional[str] = "unsafe-best-match",
dry: bool = False
) -> subprocess.CompletedProcess[Any]:
cmd = [
Expand Down Expand Up @@ -138,8 +138,8 @@ def install(
def sync(
cwd: PathLike,
reqFile: list[PathLike],
extraUrl: str | None = None,
index_strategy: str | None = "unsafe-best-match",
extraUrl: Optional[str] = None,
index_strategy: Optional[str] = "unsafe-best-match",
dry: bool = False
) -> subprocess.CompletedProcess[Any]:
cmd = [
Expand Down Expand Up @@ -169,7 +169,7 @@ def sync(
return _check_call(cmd, cwd)

@staticmethod
def resolveGpu(gpu: str | None):
def resolveGpu(gpu: Union[str, None]):
if gpu is None:
try:
tver = metadata.version("torch")
Expand All @@ -188,7 +188,7 @@ def __init__(
self,
cwd: PathLike = ".",
extDirs: list[PathLike] = [],
gpu: str | None = None,
gpu: Union[str, None] = None,
outName: str = "requirements.compiled",
):
self.cwd = Path(cwd)
Expand Down Expand Up @@ -270,7 +270,7 @@ def handleOpencv(self):
if "opencv-python==" not in line:
f.write(line)

def fastInstallComfyDeps(cwd: PathLike, gpu: str | None = None):
def fastInstallComfyDeps(cwd: PathLike, gpu: Optional[str] = None):
_check_call(cmd=["pip", "install", "uv"], cwd=cwd)

p = Path(cwd)
Expand Down

0 comments on commit d742327

Please sign in to comment.