]> granicus.if.org Git - graphviz/commitdiff
convert some legacy Python '.format' and string addition to f-strings
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 14 Nov 2021 18:20:59 +0000 (10:20 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 14 Dec 2021 01:17:49 +0000 (17:17 -0800)
Newer versions of Pylint warn about this.

gen_version.py
rtest/rtest.py
tests/regression_tests/regression_test_helpers.py

index 6bd8f393824ede00a2b026a8c89cac8f5367389c..f8430f455c72c96a420fd2dd2aa4c7d8098c9853 100644 (file)
@@ -157,7 +157,7 @@ if not patch_version.isnumeric() or args.date_format:
 
 if not patch_version.isnumeric():
   # Non-numerical patch version; add committer date
-  patch_version += "." + committer_date
+  patch_version += f".{committer_date}"
 
 if args.date_format:
   if args.definition:
index da1c4243d229113f06f02f166dc6262fd86a80b5..c95b89090f0c046e20617243affb7d453eae3d0b 100755 (executable)
@@ -117,10 +117,9 @@ def doDiff(OUTFILE, testname, subtest_index, fmt):
   if platform.system() == "Windows" and \
      F in ["ps", "gv"] and \
      testname in ["clusters", "compound", "rootlabel"]:
-    print("Warning: Skipping {0} output comparison for test {1}:{2} : format "
-          "{3} because the order of clusters in gv or ps output is not "
-          "stable on Windows (#1789)"
-          .format(F, testname, subtest_index, fmt),
+    print(f"Warning: Skipping {F} output comparison for test "
+          f"{testname}:{subtest_index} : format {fmt} because the order of "
+          "clusters in gv or ps output is not stable on Windows (#1789)",
           file=sys.stderr)
     return
   if F in ["ps", "ps2"]:
@@ -337,7 +336,7 @@ if not REFDIR:
   elif platform.system() == "Windows":
     REFDIR = "nshare"
   else:
-    print('Unrecognized system "{0}"'.format(platform.system()), file=sys.stderr)
+    print(f'Unrecognized system "{platform.system()}"', file=sys.stderr)
     REFDIR = "nshare"
 
 parser = argparse.ArgumentParser(description="Run regression tests.")
index 536beaba8e16e30306f3ef33c2f3fcb66cca33ce..be14a258d69e695b2ecd4afd5aaeed57856bf006 100644 (file)
@@ -43,7 +43,7 @@ def compare_graphs(name, output_type):
         print(line)
 
       # Store diff in file
-      with open("difference/" + str(filename), "w") as diff_file:
+      with open(f"difference/{str(filename)}", "w") as diff_file:
         diff_file.writelines(diff)
 
       print(f"Failure: {filename} - Generated file does not match reference file.")