From d003f96a9d180e658d08733a467590098f3c6ff7 Mon Sep 17 00:00:00 2001 From: morris Date: Tue, 19 May 2020 19:54:14 +0800 Subject: [PATCH] gh_action: fix python lint --- .flake8 | 3 ++- .github/workflows/python_lint.yml | 5 +++-- docs/conf_common.py | 4 ++-- docs/en/conf.py | 11 +++++++---- docs/idf_extensions/link_roles.py | 4 ++-- docs/zh_CN/conf.py | 11 +++++++---- .../advanced_tests/http_server_advanced_test.py | 2 ++ tools/kconfig_new/test/confserver/test_confserver.py | 2 +- 8 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.flake8 b/.flake8 index e98aa15f23..f935c8244c 100644 --- a/.flake8 +++ b/.flake8 @@ -141,13 +141,14 @@ exclude = __pycache__, # submodules components/bootloader/subproject/components/micro-ecc/micro-ecc, + components/bt/host/nimble/nimble, components/esptool_py/esptool, components/expat/expat, components/json/cJSON, components/libsodium/libsodium, components/mbedtls/mbedtls, components/nghttp/nghttp2, - components/bt/host/nimble/nimble, + components/tinyusb, components/unity/unity, examples/build_system/cmake/import_lib/main/lib/tinyxml2, # other third-party libraries diff --git a/.github/workflows/python_lint.yml b/.github/workflows/python_lint.yml index 07b60b47e7..b62552fe87 100644 --- a/.github/workflows/python_lint.yml +++ b/.github/workflows/python_lint.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [2.7, 3.5, 3.6, 3.7] + python-version: [2.7, 3.5, 3.6, 3.7, 3.8] steps: - name: Checkout @@ -24,9 +24,10 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | + export IDF_PATH=${GITHUB_WORKSPACE} pip install --upgrade pip pip install -r requirements.txt - name: Lint with flake8 run: | pip install flake8 - flake8 . --config=.flake8 + flake8 . --config=.flake8 --benchmark diff --git a/docs/conf_common.py b/docs/conf_common.py index e7ad6e2dd2..99ddabecce 100644 --- a/docs/conf_common.py +++ b/docs/conf_common.py @@ -207,11 +207,11 @@ project_homepage = "https://github.com/espressif/esp-idf" # Redirects should be listed in page_redirects.xt # with open("../page_redirects.txt") as f: - lines = [re.sub(" +", " ", l.strip()) for l in f.readlines() if l.strip() != "" and not l.startswith("#")] + lines = [re.sub(" +", " ", line.strip()) for line in f.readlines() if line.strip() != "" and not line.startswith("#")] for line in lines: # check for well-formed entries if len(line.split(' ')) != 2: raise RuntimeError("Invalid line in page_redirects.txt: %s" % line) -html_redirect_pages = [tuple(l.split(' ')) for l in lines] +html_redirect_pages = [tuple(line.split(' ')) for line in lines] # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. diff --git a/docs/en/conf.py b/docs/en/conf.py index aca922afec..7e6cbeea07 100644 --- a/docs/en/conf.py +++ b/docs/en/conf.py @@ -6,10 +6,13 @@ # Importing conf_common adds all the non-language-specific # parts to this conf module -import sys -import os -sys.path.insert(0, os.path.abspath('..')) -from conf_common import * # noqa: F401, F403 - need to make available everything from common +try: + from conf_common import * # noqa: F403 +except ImportError: + import sys + import os + sys.path.insert(0, os.path.abspath('..')) + from conf_common import * # noqa: F403 # General information about the project. project = u'ESP-IDF Programming Guide' diff --git a/docs/idf_extensions/link_roles.py b/docs/idf_extensions/link_roles.py index 250e46f77b..026c66202f 100644 --- a/docs/idf_extensions/link_roles.py +++ b/docs/idf_extensions/link_roles.py @@ -98,7 +98,7 @@ def github_link(link_type, idf_rev, submods, root_path, app_config): if line_no is None: warning("Line number anchor in URL %s doesn't seem to be valid" % link) else: - line_no = tuple(int(l) for l in line_no.groups() if l) # tuple of (nnn,) or (nnn, NNN) for ranges + line_no = tuple(int(ln_group) for ln_group in line_no.groups() if ln_group) # tuple of (nnn,) or (nnn, NNN) for ranges elif '#' in abs_path: # drop any other anchor from the line abs_path = abs_path.split('#')[0] warning("URL %s seems to contain an unusable anchor after the #, only line numbers are supported" % link) @@ -121,7 +121,7 @@ def github_link(link_type, idf_rev, submods, root_path, app_config): elif os.path.exists(abs_path) and not os.path.isdir(abs_path): with open(abs_path, "r") as f: lines = len(f.readlines()) - if any(True for l in line_no if l > lines): + if any(True for ln in line_no if ln > lines): warning("URL %s specifies a range larger than file (file has %d lines)" % (rel_path, lines)) if tuple(sorted(line_no)) != line_no: # second line number comes before first one! diff --git a/docs/zh_CN/conf.py b/docs/zh_CN/conf.py index 3eba509d3c..a7fed75faa 100644 --- a/docs/zh_CN/conf.py +++ b/docs/zh_CN/conf.py @@ -6,10 +6,13 @@ # Importing conf_common adds all the non-language-specific # parts to this conf module -import sys -import os -sys.path.insert(0, os.path.abspath('..')) -from conf_common import * # noqa: F401, F403 - need to make available everything from common +try: + from conf_common import * # noqa: F403 +except ImportError: + import sys + import os + sys.path.insert(0, os.path.abspath('..')) + from conf_common import * # noqa: F403 # General information about the project. project = u'ESP-IDF 编程指南' diff --git a/examples/protocols/http_server/advanced_tests/http_server_advanced_test.py b/examples/protocols/http_server/advanced_tests/http_server_advanced_test.py index a1ccdf6087..e0c9e4f46d 100644 --- a/examples/protocols/http_server/advanced_tests/http_server_advanced_test.py +++ b/examples/protocols/http_server/advanced_tests/http_server_advanced_test.py @@ -34,6 +34,8 @@ from idf_http_server_test import test as client # of large HTTP packets and malformed requests, running multiple parallel sessions, etc. # It is advised that all these tests be run locally, when making changes or adding new # features to this component. + + @ttfw_idf.idf_example_test(env_tag="Example_WIFI") def test_examples_protocol_http_server_advanced(env, extra_data): # Acquire DUT diff --git a/tools/kconfig_new/test/confserver/test_confserver.py b/tools/kconfig_new/test/confserver/test_confserver.py index 990da010f8..2153cda5fa 100755 --- a/tools/kconfig_new/test/confserver/test_confserver.py +++ b/tools/kconfig_new/test/confserver/test_confserver.py @@ -14,7 +14,7 @@ PROTOCOL_VERSIONS = [1, 2] def parse_testcases(version): with open("testcases_v%d.txt" % version, "r") as f: - cases = [l for l in f.readlines() if len(l.strip()) > 0] + cases = [line for line in f.readlines() if len(line.strip()) > 0] # Each 3 lines in the file should be formatted as: # * Description of the test change # * JSON "changes" to send to the server