From f39f8d4a3f2da1afd4dea3953f8076bb26036124 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Tue, 7 May 2024 09:16:54 +0200 Subject: [PATCH] ci: update mypy check for python 3.12, check under python 3.7 rules --- .pre-commit-config.yaml | 8 ++++---- tools/ci/check_type_comments.py | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1d25f33376..780fefd18c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -104,10 +104,10 @@ repos: name: Check type annotations in python files entry: tools/ci/check_type_comments.py additional_dependencies: - - 'mypy==0.940' - - 'mypy-extensions==0.4.3' - - 'types-setuptools==57.4.14' - - 'types-PyYAML==0.1.9' + - 'mypy' + - 'mypy-extensions' + - 'types-setuptools' + - 'types-PyYAML' exclude: > (?x)^( .*_pb2.py diff --git a/tools/ci/check_type_comments.py b/tools/ci/check_type_comments.py index d89bf562b2..d9e6c6b9af 100755 --- a/tools/ci/check_type_comments.py +++ b/tools/ci/check_type_comments.py @@ -2,7 +2,6 @@ # # SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 - import argparse import subprocess from sys import exit @@ -30,7 +29,7 @@ def types_valid_ignored_rules(file_name): # type: (str) -> bool """ Run Mypy check with rules for ignore list on the given file, return TRUE if Mypy check passes """ - mypy_exit_code = subprocess.call('mypy {} --allow-untyped-defs'.format(file_name), shell=True) + mypy_exit_code = subprocess.call('mypy {} --python-version 3.7 --allow-untyped-defs'.format(file_name), shell=True) return not bool(mypy_exit_code)