[libcxx-commits] [libcxx] [llvm] [libc++] Stop using awk in transitive includes test (PR #110554)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 30 12:01:24 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r df3f291d2a64bb01bc8fab69f296923c1c798909...27370baf43d66b436ede791dcf7d55dc19a0633b libcxx/test/libcxx/transitive_includes/expected.py libcxx/test/libcxx/transitive_includes.gen.py libcxx/test/libcxx/transitive_includes/to_csv.py
``````````

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- transitive_includes/expected.py	2024-09-30 18:55:55.000000 +0000
+++ transitive_includes/expected.py	2024-09-30 19:00:53.292975 +0000
@@ -21,15 +21,15 @@
         choices=["cxx03", "cxx11", "cxx14", "cxx20", "cxx23", "cxx26"],
     )
     parser.add_argument(
         "header",
         default=None,
-        help="The header to extract the expected transitive includes for."
+        help="The header to extract the expected transitive includes for.",
     )
     args = parser.parse_args()
 
     CSV_ROOT = os.path.dirname(__file__)
     filename = os.path.join(CSV_ROOT, f"{args.standard}.csv")
-    with open(filename, 'r') as f:
+    with open(filename, "r") as f:
         for line in f.readlines():
-            if line.startswith(args.header + ' '):
-                print(line, end='') # lines already end in newline
+            if line.startswith(args.header + " "):
+                print(line, end="")  # lines already end in newline
--- transitive_includes/to_csv.py	2024-09-30 18:55:55.000000 +0000
+++ transitive_includes/to_csv.py	2024-09-30 19:00:53.330749 +0000
@@ -38,10 +38,11 @@
 # If it is a backslash, Clang prints it escaped as two consecutive
 # backslashes, and they need to be escaped in the RE. (Use a raw string for
 # the pattern to avoid needing another level of escaping on the Python string
 # literal level.)
 LIBCXX_HEADER_REGEX = r".*c\+\+(?:/|\\\\)v[0-9]+(?:/|\\\\)(.+)"
+
 
 def is_libcxx_header(header: str) -> bool:
     """
     Returns whether a header is a libc++ header, excluding the C-compatibility headers.
     """
@@ -137,11 +138,11 @@
     )
     parser.add_argument(
         "inputs",
         default=None,
         metavar="FILE",
-        nargs='+',
+        nargs="+",
         help="One or more files containing the result of --trace-includes on the headers one wishes to graph.",
     )
     options = parser.parse_args()
 
     print_csv(create_include_graph(map(pathlib.Path, options.inputs)))

``````````

</details>


https://github.com/llvm/llvm-project/pull/110554


More information about the libcxx-commits mailing list