change typehint "a|b" operation to Union[a,b] to run on Python < 3.10

- this incompatibility was introduced by #1525 and missed during
  code review
This commit is contained in:
Lincoln Stein 2022-11-22 15:44:34 +00:00
parent 37bcf9cc47
commit 40a7f47d22

View File

@ -17,6 +17,7 @@ import transformers
import traceback import traceback
import textwrap import textwrap
import contextlib import contextlib
from typing import Union
from omegaconf import OmegaConf from omegaconf import OmegaConf
from omegaconf.errors import ConfigAttributeError from omegaconf.errors import ConfigAttributeError
from ldm.util import instantiate_from_config, ask_user from ldm.util import instantiate_from_config, ask_user
@ -388,7 +389,7 @@ class ModelCache(object):
def _has_cuda(self) -> bool: def _has_cuda(self) -> bool:
return self.device.type == 'cuda' return self.device.type == 'cuda'
def _cached_sha256(self,path,data) -> str | bytes: def _cached_sha256(self,path,data) -> Union[str, bytes]:
dirname = os.path.dirname(path) dirname = os.path.dirname(path)
basename = os.path.basename(path) basename = os.path.basename(path)
base, _ = os.path.splitext(basename) base, _ = os.path.splitext(basename)