Skip to content

Commit 945bd17

Browse files
CI: fixing the files to be complient with pre-commit hooks
1 parent 9d45d50 commit 945bd17

File tree

205 files changed

+3136
-3447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+3136
-3447
lines changed

.flake8

+2-3
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,5 @@ show_source = True
136136

137137
statistics = True
138138

139-
per-file-ignores =
140-
# Sphinx conf.py files use star imports to setup config variables
141-
docs/conf_common.py: F405
139+
exclude =
140+
components/asio/docs/conf_common.py

.git-blame-ignore-revs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Formating according pre-commit hooks
2+
3e1c3cc647b6f6d4da20b3ab979879f60229bfee

.github/workflows/target-test.yml

+29-29
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
matrix:
99
idf_ver: ["latest", "release-v4.1", "release-v4.2", "release-v4.3", "release-v4.4"]
1010
example: ["pppos_client", "modem_console", "ap_to_pppos", "simple_cmux_client"]
11-
idf_target: ["esp32"]
11+
idf_target: ["esp32"]
1212
exclude:
1313
- idf_ver: "release-v4.1"
1414
example: modem_console
@@ -57,30 +57,30 @@ jobs:
5757
cat sdkconfig.ci.usb >> sdkconfig.defaults
5858
idf.py build
5959
60-
build_mdns:
61-
strategy:
62-
matrix:
63-
idf_ver: ["latest"]
60+
build_mdns:
61+
strategy:
62+
matrix:
63+
idf_ver: ["latest"]
6464
idf_target: ["esp32", "esp32s2", "esp32c3"]
6565
config: ["eth_custom_netif", "eth_def", "eth_no_ipv6", "eth_socket"]
66-
runs-on: ubuntu-20.04
67-
container: espressif/idf:${{ matrix.idf_ver }}
68-
steps:
69-
- name: Checkout esp-protocols
70-
uses: actions/checkout@v3
71-
with:
72-
submodules: recursive
73-
- name: Build ${{ matrix.example }} with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }} for ${{ matrix.config }}
74-
env:
75-
IDF_TARGET: ${{ matrix.idf_target }}
76-
shell: bash
66+
runs-on: ubuntu-20.04
67+
container: espressif/idf:${{ matrix.idf_ver }}
68+
steps:
69+
- name: Checkout esp-protocols
70+
uses: actions/checkout@v3
71+
with:
72+
submodules: recursive
73+
- name: Build ${{ matrix.example }} with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }} for ${{ matrix.config }}
74+
env:
75+
IDF_TARGET: ${{ matrix.idf_target }}
76+
shell: bash
7777
working-directory: components/mdns/examples/
78-
run: |
79-
. ${IDF_PATH}/export.sh
78+
run: |
79+
. ${IDF_PATH}/export.sh
8080
rm -rf sdkconfig sdkconfig.defaults build build_${{ matrix.config }}
81-
cat sdkconfig.ci.${{ matrix.config }} >> sdkconfig.defaults
82-
idf.py set-target ${{ matrix.idf_target }}
83-
idf.py build
81+
cat sdkconfig.ci.${{ matrix.config }} >> sdkconfig.defaults
82+
idf.py set-target ${{ matrix.idf_target }}
83+
idf.py build
8484
mv build build_${{ matrix.config }}
8585
- name: Merge binaries with IDF-${{ matrix.idf_ver }} for ${{ matrix.config }}
8686
working-directory: components/mdns/examples
@@ -118,7 +118,7 @@ jobs:
118118
- name: Checkout esp-protocols
119119
uses: actions/checkout@v3
120120
with:
121-
submodules: recursive
121+
submodules: recursive
122122
- name: Build ${{ matrix.example }} with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
123123
working-directory: components/asio/examples/${{ matrix.example }}
124124
env:
@@ -234,9 +234,9 @@ jobs:
234234
path: components/esp_websocket_client/examples/*.xml
235235

236236
run-target-mdns:
237-
strategy:
238-
matrix:
239-
idf_ver: ["latest"]
237+
strategy:
238+
matrix:
239+
idf_ver: ["latest"]
240240
idf_target: ["esp32"]
241241
config: ["eth_custom_netif", "eth_def", "eth_no_ipv6", "eth_socket"]
242242
name: Run mDNS Example Test on target
@@ -267,7 +267,7 @@ jobs:
267267
run: |
268268
rm -rf build
269269
mv build_${{ matrix.config }} build
270-
cat sdkconfig.ci.${{ matrix.config }} >> sdkconfig.defaults
270+
cat sdkconfig.ci.${{ matrix.config }} >> sdkconfig.defaults
271271
python -m pytest --log-cli-level DEBUG --junit-xml=./examples_results_${{ matrix.idf_target }}_${{ matrix.idf_ver }}_${{ matrix.config }}.xml --target=${{ matrix.idf_target }}
272272
rm -rf build sdkconfig.defaults
273273
- uses: actions/upload-artifact@v2
@@ -277,9 +277,9 @@ jobs:
277277
path: components/mdns/examples/*.xml
278278

279279
run-target-asio:
280-
strategy:
281-
matrix:
282-
idf_ver: ["latest"]
280+
strategy:
281+
matrix:
282+
idf_ver: ["latest"]
283283
idf_target: ["esp32"]
284284
example: ["asio_chat", "tcp_echo_server", "udp_echo_server", "ssl_client_server"]
285285
name: Run ASIO Example Test on target

.mypy.ini

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[mypy]
2+
3+
# Specifies the Python version used to parse and check the target program
4+
python_version = 3.9
5+
6+
# Disallows defining functions without type annotations or with incomplete type annotations
7+
# True => enforce type annotation in all function definitions
8+
disallow_untyped_defs = True
9+
10+
# Shows a warning when returning a value with type Any from a function declared with a non- Any return type
11+
warn_return_any = True
12+
13+
# Shows errors for missing return statements on some execution paths
14+
warn_no_return = True
15+
16+
# Suppress error messages about imports that cannot be resolved
17+
# True => ignore all import errors
18+
ignore_missing_imports = True
19+
20+
# Disallows defining functions with incomplete type annotations
21+
disallow_incomplete_defs = False
22+
23+
# Directs what to do with imports when the imported module is found as a .py file and not part of the files,
24+
# modules and packages provided on the command line.
25+
# SKIP -> mypy checks only single file, not included imports
26+
follow_imports = skip

.pre-commit-config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ repos:
2020
rev: v0.981
2121
hooks:
2222
- id: mypy
23+
exclude: >
24+
(?x)^(
25+
.*.py
26+
)$
2327
- repo: https://github.com/myint/unify
2428
rev: v0.5
2529
hooks:

ci/check_copyright_config.yaml

+11-1
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,19 @@ asio_component:
4646
- Apache-2.0
4747
- BSL-1.0
4848

49+
slim_modem_examples:
50+
include:
51+
- 'examples/esp_netif/slip_custom_netif/**'
52+
allowed_licenses:
53+
- Apache-2.0
54+
- Unlicense
55+
- CC0-1.0
56+
4957
ignore:
5058
perform_check: no
5159
include:
5260
- 'components/**/docs/**'
5361
- 'components/esp_modem/port/linux/**'
54-
- 'components/asio/examples/asio_chat/main/*'
62+
- 'components/asio/examples/**'
63+
- 'components/mdns/**/esp_system_protocols_linux/**'
64+
- 'common_components/protocol_examples_common/**'

common_components/protocol_examples_common/addr_from_stdin.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ esp_err_t get_addr_from_stdin(int port, int sock_type, int *ip_protocol, int *ad
2626
do {
2727
fgets(host_ip, HOST_IP_SIZE, stdin);
2828
len = strlen(host_ip);
29-
} while (len<=1 && host_ip[0] == '\n');
29+
} while (len <= 1 && host_ip[0] == '\n');
3030
host_ip[len - 1] = '\0';
3131

3232
struct addrinfo hints, *addr_list, *cur;
@@ -36,16 +36,16 @@ esp_err_t get_addr_from_stdin(int port, int sock_type, int *ip_protocol, int *ad
3636
hints.ai_family = AF_UNSPEC;
3737
hints.ai_socktype = sock_type;
3838
hints.ai_protocol = IPPROTO_TCP;
39-
if( getaddrinfo( host_ip, NULL, &hints, &addr_list ) != 0 ) {
39+
if ( getaddrinfo( host_ip, NULL, &hints, &addr_list ) != 0 ) {
4040
return ESP_FAIL;
4141
}
42-
for( cur = addr_list; cur != NULL; cur = cur->ai_next ) {
42+
for ( cur = addr_list; cur != NULL; cur = cur->ai_next ) {
4343
memcpy(dest_addr, cur->ai_addr, sizeof(*dest_addr));
4444
if (cur->ai_family == AF_INET) {
4545
*ip_protocol = IPPROTO_IP;
4646
*addr_family = AF_INET;
4747
// add port number and return on first IPv4 match
48-
((struct sockaddr_in*)dest_addr)->sin_port = htons(port);
48+
((struct sockaddr_in *)dest_addr)->sin_port = htons(port);
4949
freeaddrinfo( addr_list );
5050
return ESP_OK;
5151

@@ -55,8 +55,8 @@ esp_err_t get_addr_from_stdin(int port, int sock_type, int *ip_protocol, int *ad
5555
*ip_protocol = IPPROTO_IPV6;
5656
*addr_family = AF_INET6;
5757
// add port and interface number and return on first IPv6 match
58-
((struct sockaddr_in6*)dest_addr)->sin6_port = htons(port);
59-
((struct sockaddr_in6*)dest_addr)->sin6_scope_id = esp_netif_get_netif_impl_index(EXAMPLE_INTERFACE);
58+
((struct sockaddr_in6 *)dest_addr)->sin6_port = htons(port);
59+
((struct sockaddr_in6 *)dest_addr)->sin6_scope_id = esp_netif_get_netif_impl_index(EXAMPLE_INTERFACE);
6060
freeaddrinfo( addr_list );
6161
return ESP_OK;
6262
}

common_components/protocol_examples_common/connect.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
/* Common functions for protocol examples, to establish Wi-Fi or Ethernet connection.
2-
3-
This example code is in the Public Domain (or CC0 licensed, at your option.)
1+
/*
2+
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Unlicense OR CC0-1.0
5+
*/
46

5-
Unless required by applicable law or agreed to in writing, this
6-
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
7-
CONDITIONS OF ANY KIND, either express or implied.
7+
/*
8+
* Common functions for protocol examples, to establish Wi-Fi or Ethernet connection.
89
*/
910

1011
#include <string.h>

common_components/protocol_examples_common/include/addr_from_stdin.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Unlicense OR CC0-1.0
5+
*/
6+
17
/* Common utilities for socket address input interface:
28
The API get_addr_from_stdin() is mainly used by socket client examples which read IP address from stdin (if configured).
39
This option is typically used in the CI, but could be enabled in the project configuration.
410
In that case this component is used to receive a string that is evaluated and processed to output
511
socket structures to open a connectio
6-
This example code is in the Public Domain (or CC0 licensed, at your option.)
7-
8-
Unless required by applicable law or agreed to in writing, this
9-
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10-
CONDITIONS OF ANY KIND, either express or implied.
1112
*/
1213

1314
#pragma once

common_components/protocol_examples_common/include/protocol_examples_common.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
/* Common functions for protocol examples, to establish Wi-Fi or Ethernet connection.
2-
3-
This example code is in the Public Domain (or CC0 licensed, at your option.)
1+
/*
2+
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Unlicense OR CC0-1.0
5+
*/
46

5-
Unless required by applicable law or agreed to in writing, this
6-
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
7-
CONDITIONS OF ANY KIND, either express or implied.
7+
/*
8+
* Common functions for protocol examples, to establish Wi-Fi or Ethernet connection.
89
*/
910

1011
#pragma once

common_components/protocol_examples_common/stdin_out.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
/* Common functions for protocol examples, to configure stdin and stdout.
2-
3-
This example code is in the Public Domain (or CC0 licensed, at your option.)
1+
/*
2+
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Unlicense OR CC0-1.0
5+
*/
46

5-
Unless required by applicable law or agreed to in writing, this
6-
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
7-
CONDITIONS OF ANY KIND, either express or implied.
7+
/*
8+
* Common functions for protocol examples, to configure stdin and stdout.
89
*/
910

1011
#include "protocol_examples_common.h"
@@ -19,7 +20,7 @@ esp_err_t example_configure_stdin_stdout(void)
1920
setvbuf(stdin, NULL, _IONBF, 0);
2021
/* Install UART driver for interrupt-driven reads and writes */
2122
ESP_ERROR_CHECK( uart_driver_install( (uart_port_t)CONFIG_ESP_CONSOLE_UART_NUM,
22-
256, 0, 0, NULL, 0) );
23+
256, 0, 0, NULL, 0) );
2324
/* Tell VFS to use UART driver */
2425
esp_vfs_dev_uart_use_driver(CONFIG_ESP_CONSOLE_UART_NUM);
2526
esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_ESP_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR);

components/asio/docs/conf_common.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from esp_docs.conf_docs import * # noqa: F403,F401
22

3-
extensions += ['sphinx_copybutton',
4-
# Needed as a trigger for running doxygen
5-
'esp_docs.esp_extensions.dummy_build_system',
6-
'esp_docs.esp_extensions.run_doxygen',
7-
]
3+
extensions += [
4+
'sphinx_copybutton',
5+
# Needed as a trigger for running doxygen
6+
'esp_docs.esp_extensions.dummy_build_system',
7+
'esp_docs.esp_extensions.run_doxygen',
8+
]
89

910
# link roles config
1011
github_repo = 'espressif/esp-protocols'
@@ -14,7 +15,7 @@
1415
html_context['github_repo'] = 'esp-protocols'
1516

1617
# Extra options required by sphinx_idf_theme
17-
project_slug = 'esp-idf' # >=5.0
18+
project_slug = 'esp-idf' # >=5.0
1819
versions_url = 'https://github.com/espressif/esp-protocols/docs/docs_versions.js'
1920

2021
idf_targets = ['esp32']

components/asio/docs/generate_docs

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ window.onload =(function() {
1313
mySpan.value = 'latest';
1414
mySpan.setAttribute('disabled', true);
1515
myAnchor.parentNode.replaceChild(mySpan, myAnchor);
16-
16+
1717
var myAnchor = document.getElementById('target-select');
1818
var mySpan = document.createElement('input');
1919
mySpan.setAttribute('type', 'text');
@@ -24,4 +24,3 @@ window.onload =(function() {
2424

2525
})();
2626
</script>" >> html/index.html
27-

components/asio/docs/zh_CN/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.. include:: ../../../en/api-reference/protocols/asio.rst
1+
.. include:: ../../../en/api-reference/protocols/asio.rst

components/asio/examples/asio_chat/main/asio_chat.cpp

+17-16
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ void start_client(void)
5353
#ifdef CONFIG_EXAMPLE_CHAT_SERVER
5454
std::lock_guard<std::mutex> guard(server_ready);
5555
#endif
56-
std::thread t([&io_context]() { try {
57-
io_context.run();
58-
} catch (const std::exception &e) {
59-
ESP_LOGE(TAG, "Exception occured during client thread execution %s", e.what());
60-
}
61-
catch (...) {
62-
ESP_LOGE(TAG, "Unknown exception");
63-
}});
56+
std::thread t([&io_context]() {
57+
try {
58+
io_context.run();
59+
} catch (const std::exception &e) {
60+
ESP_LOGE(TAG, "Exception occured during client thread execution %s", e.what());
61+
} catch (...) {
62+
ESP_LOGE(TAG, "Unknown exception");
63+
}
64+
});
6465
do {
6566
ESP_LOGI(TAG, "CLIENT: Waiting for input");
6667
get_string(line, sizeof(line));
@@ -95,14 +96,14 @@ extern "C" void app_main(void)
9596
asio::io_context io_context;
9697
chat_server server(io_context, tcp::endpoint(tcp::v4(), std::atoi(CONFIG_EXAMPLE_CHAT_SERVER_BIND_PORT)));
9798
std::thread t = std::thread([&io_context]() { // Chat server starting here
98-
try {
99-
io_context.run();
100-
} catch (const std::exception &e) {
101-
ESP_LOGE(TAG, "Exception occured during server thread execution %s", e.what());
102-
}
103-
catch (...) {
104-
ESP_LOGE(TAG, "Unknown exception");
105-
}});;
99+
try {
100+
io_context.run();
101+
} catch (const std::exception &e) {
102+
ESP_LOGE(TAG, "Exception occured during server thread execution %s", e.what());
103+
} catch (...) {
104+
ESP_LOGE(TAG, "Unknown exception");
105+
}
106+
});;
106107
#endif
107108
#ifdef CONFIG_EXAMPLE_CHAT_CLIENT
108109
start_client();

0 commit comments

Comments
 (0)