未验证 提交 599e9e48 编写于 作者: Z zhangchunle 提交者: GitHub

fix too-many-format-args (#33353)

上级 cb12282e
......@@ -167,8 +167,8 @@ def run_convert():
os.path.getsize(output_file) == FULL_SIZE_BYTES):
if os.path.exists(output_file):
sys.stderr.write(
"\n\nThe existing binary file is broken. Start to generate new one...\n\n".
format(output_file))
"\n\nThe existing binary file is broken. Start to generate new one...\n\n"
)
os.remove(output_file)
if retry < try_limit:
retry = retry + 1
......
......@@ -286,7 +286,7 @@ class DistributedStrategy(object):
self.a_sync_configs = {"k_steps": 0}
else:
raise ValueError(
"The type of `flag` is invalid, expected type is bool, but received %s".
"The type of `flag` is invalid, expected type is bool, but received {}".
format(type(flag)))
@property
......
......@@ -195,7 +195,7 @@ class Pod(object):
self.id != pod.id or \
self.addr != pod.addr or \
self.port != pod.port:
logger.debug("pod {} != pod".format(self, pod))
logger.debug("pod {} != {}".format(self, pod))
return False
if len(self.trainers) != len(pod.trainers):
......
......@@ -368,7 +368,8 @@ def insert_reduce_ops(block,
for var in reduce_vars:
root_id = get_grad_device(var, shard)
assert root_id >= 0, "root id should be a positive int".format(var)
assert root_id >= 0, "root id should be a positive int, but now root id is {}".format(
root_id)
block._insert_op_without_sync(
insert_idx,
type='c_reduce_sum',
......
......@@ -841,8 +841,7 @@ class HDFSClient(FS):
fs_src_path))
if self.is_exist(fs_dst_path):
raise FSFileExistsError("{} exists already".format(
fs_src_path, fs_dst_path, fs_dst_path))
raise FSFileExistsError("{} exists already".format(fs_dst_path))
return self._try_mv(fs_src_path, fs_dst_path)
......
......@@ -264,7 +264,7 @@ class Pod(object):
self.id != pod.id or \
self.addr != pod.addr or \
self.port != pod.port:
logger.debug("pod {} != pod".format(self, pod))
logger.debug("pod {} != {}".format(self, pod))
return False
if len(self.trainers) != len(pod.trainers):
......
......@@ -2142,7 +2142,7 @@ class Operator(object):
"""
assert isinstance(
skip_op_callstack, bool
), "skip_op_callstack parameter's type is error, expect bool, received %s".format(
), "skip_op_callstack parameter's type is error, expect bool, received {}".format(
type(skip_op_callstack))
outputs_str = "{"
for i in range(0, len(self.output_names)):
......@@ -2550,7 +2550,7 @@ class Block(object):
"""
assert isinstance(
skip_op_callstack, bool
), "skip_op_callstack parameter's type is error, expect bool, received %s".format(
), "skip_op_callstack parameter's type is error, expect bool, received {}".format(
type(skip_op_callstack))
block_str = "{ // block "
block_str += "{}\n".format(self.idx)
......@@ -4259,7 +4259,7 @@ class Program(object):
"""
assert isinstance(
skip_op_callstack, bool
), "skip_op_callstack parameter's type is error, expect bool, received %s".format(
), "skip_op_callstack parameter's type is error, expect bool, received {}".format(
type(skip_op_callstack))
program_str = ""
for block in self.blocks:
......
......@@ -268,8 +268,7 @@ class HDFSClient(FS):
fs_src_path))
if self.is_exist(fs_dst_path):
raise FSFileExistsError("{} exists already".format(
fs_src_path, fs_dst_path, fs_dst_path))
raise FSFileExistsError("{} exists already".format(fs_dst_path))
return self._try_mv(fs_src_path, fs_dst_path)
......
......@@ -246,7 +246,7 @@ def inject_test_train(use_cuda):
def inject_test_decode(use_cuda, decorator=None):
f_name = 'test_{0}_decode'.format('cuda' if use_cuda else 'cpu', 'sparse')
f_name = 'test_{0}_decode'.format('cuda' if use_cuda else 'cpu')
def f(*args):
with scope_prog_guard():
......
......@@ -72,7 +72,7 @@ class TestTracedLayerErrMsg(unittest.TestCase):
self.layer, 3)
self.assertEqual(
"The type of 'each element of inputs' in fluid.dygraph.jit.TracedLayer.trace must be fluid.Variable, but received <{} 'int'>.".
format(self.type_str, self.type_str), str(e.exception))
format(self.type_str), str(e.exception))
with self.assertRaises(TypeError) as e:
dygraph_out, traced_layer = fluid.dygraph.TracedLayer.trace(
self.layer, [True, 1])
......
......@@ -392,7 +392,8 @@ def adjust_hue(img, hue_factor):
cv2 = try_import('cv2')
if not (-0.5 <= hue_factor <= 0.5):
raise ValueError('hue_factor is not in [-0.5, 0.5].'.format(hue_factor))
raise ValueError('hue_factor:{} is not in [-0.5, 0.5].'.format(
hue_factor))
dtype = img.dtype
img = img.astype(np.uint8)
......
......@@ -378,7 +378,8 @@ def adjust_hue(img, hue_factor):
"""
if not (-0.5 <= hue_factor <= 0.5):
raise ValueError('hue_factor is not in [-0.5, 0.5].'.format(hue_factor))
raise ValueError('hue_factor:{} is not in [-0.5, 0.5].'.format(
hue_factor))
input_mode = img.mode
if input_mode in {'L', '1', 'I', 'F'}:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册