style(ci): satisfy ruff on check_type_comments.py

The previous commit touches tools/ci/check_type_comments.py, which brings the
file into ruff's scope for the first time in a while and surfaces two
pre-existing findings:

    A004 Import `exit` is shadowing a Python builtin
    F401 `typing.List` imported but unused

Import sys and call sys.exit() rather than shadowing the builtin, which is
also how master writes this file. List is used, but only inside `# type:`
comments that ruff cannot see, so mark the import instead of dropping it:
check_type_comments.py is not on tools/ci/mypy_ignore_list.txt, so mypy checks
it under disallow_untyped_defs and the name has to resolve.

No behaviour change. Verified with the pinned ruff 0.9.7 (check and
format --check) and with mypy 1.19.1, and both exit paths of the script still
behave as before.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2026-08-17 16:56:14 +02:00
parent 2a92260bc1
commit 3c9d844cbe
+3 -3
View File
@@ -4,10 +4,10 @@
# SPDX-License-Identifier: Apache-2.0
import argparse
import subprocess
from sys import exit
import sys
try:
from typing import List
from typing import List # noqa: F401
except ImportError:
# Only used for type annotations
pass
@@ -84,7 +84,7 @@ def main(): # type: () -> None
print('mypy check failed for:')
for file_name in type_issues:
print('\t', file_name)
exit(1)
sys.exit(1)
if __name__ == '__main__':