[clang-tools-extra] [clang-tidy] remove type annotations that require python3.9 in add_new_check.py (PR #107850)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 9 05:07:11 PDT 2024


https://github.com/5chmidti created https://github.com/llvm/llvm-project/pull/107850

Subscripting `Tuple`: `Tuple[str, str]` is not supported until python 3.9.
Tested with python 3.8.19, 3.9.19 and 3.12.4.

Fixes #107846


>From 36fff2ffdb29d8510c31464f6f6aad97721607c9 Mon Sep 17 00:00:00 2001
From: Julian Schmidt <git.julian.schmidt at gmail.com>
Date: Mon, 9 Sep 2024 14:03:12 +0200
Subject: [PATCH] [clang-tidy] remove type annotations that require python3.9
 in add_new_check.py

Subscripting `Tuple`: `Tuple[str, str]` is not supported until python 3.9.
Tested with python 3.8.19, 3.9.19 and 3.12.4.

Fixes #107846
---
 clang-tools-extra/clang-tidy/add_new_check.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/add_new_check.py b/clang-tools-extra/clang-tidy/add_new_check.py
index d384dbae28abbc..7230b3b17b2b79 100755
--- a/clang-tools-extra/clang-tidy/add_new_check.py
+++ b/clang-tools-extra/clang-tidy/add_new_check.py
@@ -511,7 +511,7 @@ def has_auto_fix(check_name: str) -> str:
 
         return ""
 
-    def process_doc(doc_file: Tuple[str, str]) -> Tuple[str, Optional[re.Match[str]]]:
+    def process_doc(doc_file):
         check_name = doc_file[0] + "-" + doc_file[1].replace(".rst", "")
 
         with io.open(os.path.join(docs_dir, *doc_file), "r", encoding="utf8") as doc:
@@ -526,7 +526,7 @@ def process_doc(doc_file: Tuple[str, str]) -> Tuple[str, Optional[re.Match[str]]
             # Is it a redirect?
             return check_name, match
 
-    def format_link(doc_file: Tuple[str, str]) -> str:
+    def format_link(doc_file) -> str:
         check_name, match = process_doc(doc_file)
         if not match and check_name and not check_name.startswith("clang-analyzer-"):
             return "   :doc:`%(check_name)s <%(module)s/%(check)s>`,%(autofix)s\n" % {
@@ -538,7 +538,7 @@ def format_link(doc_file: Tuple[str, str]) -> str:
         else:
             return ""
 
-    def format_link_alias(doc_file: Tuple[str, str]) -> str:
+    def format_link_alias(doc_file) -> str:
         check_name, match = process_doc(doc_file)
         if (match or (check_name.startswith("clang-analyzer-"))) and check_name:
             module = doc_file[0]



More information about the cfe-commits mailing list