Skip to content

[CodeStyle][UP030][UP031][UP032] using f-string #52062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions cmake/copyfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ def main():
dst = os.path.join(dst, pathList[-1])
if not os.path.exists(dst):
shutil.copytree(src, dst)
print("first copy directory: {0} --->>> {1}".format(src, dst))
print(f"first copy directory: {src} --->>> {dst}")
else:
shutil.rmtree(dst)
shutil.copytree(src, dst)
print("overwritten copy directory: {0} --->>> {1}".format(src, dst))
print(f"overwritten copy directory: {src} --->>> {dst}")
else: # copy file, wildcard
if not os.path.exists(dst):
os.makedirs(dst)
srcFiles = glob.glob(src)
for srcFile in srcFiles:
shutil.copy(srcFile, dst)
print("copy file: {0} --->>> {1}".format(srcFile, dst))
print(f"copy file: {srcFile} --->>> {dst}")


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def DetermineForwardPositionMap(
if len(forward_returns_list) == 1:
return_name = "out"
else:
return_name = "out_{}".format(i + 1)
return_name = f"out_{i + 1}"
else:
return_name = forward_return[0]
return_type = forward_return[1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def download_concat(cache_folder, zip_path):
download(data_urls[i], cache_folder, data_md5s[i])
file_name = os.path.join(cache_folder, data_urls[i].split('/')[-1])
file_names.append(file_name)
print("Downloaded part {0}\n".format(file_name))
print(f"Downloaded part {file_name}\n")
with open(zip_path, "wb") as outfile:
for fname in file_names:
shutil.copyfileobj(open(fname, 'rb'), outfile)
Expand Down Expand Up @@ -174,13 +174,13 @@ def run_convert():
retry = retry + 1
else:
raise RuntimeError(
"Can not convert the dataset to binary file with try limit {0}".format(
"Can not convert the dataset to binary file with try limit {}".format(
try_limit
)
)
download_concat(cache_folder, zip_path)
convert_Imagenet_tar2bin(zip_path, output_file)
print("\nSuccess! The binary file can be found at {0}".format(output_file))
print(f"\nSuccess! The binary file can be found at {output_file}")


def convert_Imagenet_local2bin(args):
Expand Down Expand Up @@ -231,7 +231,7 @@ def convert_Imagenet_local2bin(args):
)
if os.path.getsize(bin_file_path) == target_size:
print(
"Success! The user data output binary file can be found at: {0}".format(
"Success! The user data output binary file can be found at: {}".format(
bin_file_path
)
)
Expand Down
10 changes: 5 additions & 5 deletions paddle/fluid/operators/generator/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class {to_pascal_case(op_name)}InferVarType


def quote(s):
return '"{}"'.format(s)
return f'"{s}"'


# ------------------------------ attr -------------------------------------
Expand Down Expand Up @@ -132,16 +132,16 @@ def filter_intermediate(items: Sequence):
# -------------- transform argument names from yaml to opmaker ------------
def to_opmaker_name(s):
if s.endswith("_grad"):
return 'GradVarName("{}")'.format(s[:-5])
return f'GradVarName("{s[:-5]}")'
else:
return '"{}"'.format(s)
return f'"{s}"'


def to_opmaker_name_cstr(s):
if s.endswith("_grad"):
return '"{}@GRAD"'.format(s[:-5])
return f'"{s[:-5]}@GRAD"'
else:
return '"{}"'.format(s)
return f'"{s}"'


def to_pascal_case(s):
Expand Down
Loading