pass tuple for strs to startswith (#2986)

This commit is contained in:
chenyu
2024-01-02 19:51:15 -05:00
committed by GitHub
parent dbe4a1a914
commit 08a34faea8
2 changed files with 2 additions and 2 deletions

View File

@@ -93,5 +93,5 @@ def least_upper_dtype(*ds:DType) -> DType:
def least_upper_float(dt:DType) -> DType: return dt if dtypes.is_float(dt) else least_upper_dtype(dt, dtypes.float32)
# HACK: staticmethods are not callable in 3.8 so we have to compare the class
DTYPES_DICT = {k: v for k, v in dtypes.__dict__.items() if not (k.startswith('__') or k.startswith('default') or v.__class__ is staticmethod)}
DTYPES_DICT = {k: v for k, v in dtypes.__dict__.items() if not (k.startswith(('__', 'default')) or v.__class__ is staticmethod)}
INVERSE_DTYPES_DICT = {v:k for k,v in DTYPES_DICT.items()}

View File

@@ -147,7 +147,7 @@ def diskcache_put(table:str, key:Union[Dict, str, int], val:Any):
# *** http support ***
def fetch(url:str, name:Optional[Union[pathlib.Path, str]]=None, allow_caching=not getenv("DISABLE_HTTP_CACHE")) -> pathlib.Path:
if url.startswith("/") or url.startswith("."): return pathlib.Path(url)
if url.startswith(("/", ".")): return pathlib.Path(url)
fp = pathlib.Path(name) if name is not None and (isinstance(name, pathlib.Path) or '/' in name) else pathlib.Path(_cache_dir) / "tinygrad" / "downloads" / (name if name else hashlib.md5(url.encode('utf-8')).hexdigest()) # noqa: E501
if not fp.is_file() or not allow_caching:
with request.urlopen(url, timeout=10) as r: