change: fix linting errors in python files

This commit is contained in:
Peter Dragun
2025-07-28 10:11:04 +02:00
parent 519042a1e2
commit 300ff9fc78
3 changed files with 26 additions and 48 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0
#
@@ -11,32 +11,24 @@
# (python3.10, python3.11, ...) cannot be hardcoded there and at the end, the user is responsible to set-up a system
# where "python" or "python3" of compatible version is available.
import sys
try:
# Python 2 is not supported anymore but still the old way of typing is used here in order to give a nice Python
# version failure and not a typing exception.
from typing import Iterable
except ImportError:
pass
from collections.abc import Iterable
OLDEST_PYTHON_SUPPORTED = (3, 10) # keep it as tuple for comparison with sys.version_info
def _ver_to_str(it): # type: (Iterable) -> str
def _ver_to_str(it: Iterable) -> str:
return '.'.join(str(x) for x in it)
def is_supported(): # type: () -> bool
def is_supported() -> bool:
return sys.version_info[:2] >= OLDEST_PYTHON_SUPPORTED[:2]
def check(): # type: () -> None
def check() -> None:
if not is_supported():
raise RuntimeError(
'ESP-IDF supports Python {} or newer but you are using Python {}. Please upgrade your '
'installation as described in the documentation.'.format(
_ver_to_str(OLDEST_PYTHON_SUPPORTED), _ver_to_str(sys.version_info[:3])
)
f'ESP-IDF supports Python {_ver_to_str(OLDEST_PYTHON_SUPPORTED)} or newer but you are using Python '
f'{_ver_to_str(sys.version_info[:3])}. Please upgrade your installation as described in the documentation.'
)