Use Python 3.9 syntax in tests (#37343)
Signed-off-by: cyy <cyyever@outlook.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
# coding=utf-8
|
||||
# Copyright 2019 HuggingFace Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -236,7 +235,7 @@ if is_torch_available():
|
||||
except OSError:
|
||||
LOG.info("Loading model %s in offline mode failed as expected", TINY_IMAGE_CLASSIF)
|
||||
else:
|
||||
self.fail("Loading model {} in offline mode should fail".format(TINY_IMAGE_CLASSIF))
|
||||
self.fail(f"Loading model {TINY_IMAGE_CLASSIF} in offline mode should fail")
|
||||
|
||||
# Download model -> Huggingface Hub not concerned by our offline mode
|
||||
LOG.info("Downloading %s for offline tests", TINY_IMAGE_CLASSIF)
|
||||
@@ -280,7 +279,7 @@ if is_torch_available():
|
||||
except OSError:
|
||||
LOG.info("Loading model %s in offline mode failed as expected", TINY_IMAGE_CLASSIF)
|
||||
else:
|
||||
self.fail("Loading model {} in offline mode should fail".format(TINY_IMAGE_CLASSIF))
|
||||
self.fail(f"Loading model {TINY_IMAGE_CLASSIF} in offline mode should fail")
|
||||
|
||||
LOG.info("Downloading %s for offline tests", TINY_IMAGE_CLASSIF)
|
||||
hub_api = HfApi()
|
||||
@@ -574,7 +573,7 @@ class ModelUtilsTest(TestCasePlus):
|
||||
|
||||
def remove_torch_dtype(model_path):
|
||||
file = f"{model_path}/config.json"
|
||||
with open(file, "r", encoding="utf-8") as f:
|
||||
with open(file, encoding="utf-8") as f:
|
||||
s = json.load(f)
|
||||
s.pop("torch_dtype")
|
||||
with open(file, "w", encoding="utf-8") as f:
|
||||
@@ -745,7 +744,7 @@ class ModelUtilsTest(TestCasePlus):
|
||||
self.assertEqual(len(state_dict), 1)
|
||||
|
||||
# Check the index and the shard files found match
|
||||
with open(index_file, "r", encoding="utf-8") as f:
|
||||
with open(index_file, encoding="utf-8") as f:
|
||||
index = json.loads(f.read())
|
||||
|
||||
all_shards = set(index["weight_map"].values())
|
||||
|
||||
Reference in New Issue
Block a user