mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-05 21:00:04 +00:00
change: fix linting errors in python files
This commit is contained in:
@@ -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.'
|
||||
)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user