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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tidy

Author: Julian Schmidt (5chmidti)

<details>
<summary>Changes</summary>

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


---
Full diff: https://github.com/llvm/llvm-project/pull/107850.diff


1 Files Affected:

- (modified) clang-tools-extra/clang-tidy/add_new_check.py (+3-3) 


``````````diff
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]

``````````

</details>


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


More information about the cfe-commits mailing list