Skip to content

Commit 3367e1c

Browse files
committed
Merge bitcoin/bitcoin#28009: script, test: python typing and linter updates
6c97757 script: appease spelling linter (Jon Atack) 1316119 script: update ignored-words.txt (Jon Atack) 146c861 script: update linter dependencies (Jon Atack) 9240822 test: fix PEP484 no implicit optional argument types errors (Jon Atack) f86a301 script, test: add missing python type annotations (Jon Atack) Pull request description: With these updates, `./test/lint/lint-python.py` and `./test/lint/lint-spelling.py` should be green again for developers using relatively recent Python dependencies, in particular mypy 0.991 (released 11/2022) and later. Please see the commit messages for details. ACKs for top commit: fanquake: ACK 6c97757 Tree-SHA512: 8a46a4d36d5978affdcecf4f2ace20ca1b52d483e098304911a2169afe60ccb9b042fa90c04b762d94f3ce53d2cafe6f24476ae839867a770c7f31e7e7242d99
2 parents f8a71f3 + 6c97757 commit 3367e1c

File tree

10 files changed

+18
-14
lines changed

10 files changed

+18
-14
lines changed

ci/lint/04_install.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ if [ -z "${SKIP_PYTHON_INSTALL}" ]; then
3333
python3 --version
3434
fi
3535

36-
${CI_RETRY_EXE} pip3 install codespell==2.2.1
37-
${CI_RETRY_EXE} pip3 install flake8==5.0.4
38-
${CI_RETRY_EXE} pip3 install lief==0.13.1
39-
${CI_RETRY_EXE} pip3 install mypy==0.971
40-
${CI_RETRY_EXE} pip3 install pyzmq==24.0.1
36+
${CI_RETRY_EXE} pip3 install codespell==2.2.5
37+
${CI_RETRY_EXE} pip3 install flake8==6.0.0
38+
${CI_RETRY_EXE} pip3 install lief==0.13.2
39+
${CI_RETRY_EXE} pip3 install mypy==1.4.1
40+
${CI_RETRY_EXE} pip3 install pyzmq==25.1.0
4141
${CI_RETRY_EXE} pip3 install vulture==2.6
4242

4343
SHELLCHECK_VERSION=v0.8.0

contrib/devtools/test-security-check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def clean_files(source, executable):
2828
os.remove(source)
2929
os.remove(executable)
3030

31-
def call_security_check(cc, source, executable, options):
31+
def call_security_check(cc: str, source: str, executable: str, options) -> tuple:
3232
# This should behave the same as AC_TRY_LINK, so arrange well-known flags
3333
# in the same order as autoconf would.
3434
#

src/addrdb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ util::Result<std::unique_ptr<AddrMan>> LoadAddrman(const NetGroupManager& netgro
210210
return util::Error{strprintf(_("Invalid or corrupt peers.dat (%s). If you believe this is a bug, please report it to %s. As a workaround, you can move the file (%s) out of the way (rename, move, or delete) to have a new one created on the next start."),
211211
e.what(), PACKAGE_BUGREPORT, fs::quoted(fs::PathToString(path_addr)))};
212212
}
213-
return {std::move(addrman)}; // std::move should be unneccessary but is temporarily needed to work around clang bug
213+
return {std::move(addrman)}; // std::move should be unnecessary but is temporarily needed to work around clang bug
214214
// (https://github.com/bitcoin/bitcoin/pull/25977#issuecomment-1561270092)
215215
}
216216

src/test/miniminer_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,8 @@ BOOST_FIXTURE_TEST_CASE(calculate_cluster, TestChain100Setup)
463463
}
464464
const auto vec_iters_zigzag = pool.GetIterVec(zigzag_txids);
465465
// It doesn't matter which tx we calculate cluster for, everybody is in it.
466-
const std::vector<size_t> indeces{0, 22, 72, zigzag_txids.size() - 1};
467-
for (const auto index : indeces) {
466+
const std::vector<size_t> indices{0, 22, 72, zigzag_txids.size() - 1};
467+
for (const auto index : indices) {
468468
const auto cluster = pool.GatherClusters({zigzag_txids[index]});
469469
BOOST_CHECK_EQUAL(cluster.size(), zigzag_txids.size());
470470
CTxMemPool::setEntries clusterset{cluster.begin(), cluster.end()};

test/functional/interface_rest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
MiniWallet,
2727
getnewdestination,
2828
)
29+
from typing import Optional
2930

3031

3132
INVALID_PARAM = "abc"
@@ -64,7 +65,7 @@ def test_rest_request(
6465
body: str = '',
6566
status: int = 200,
6667
ret_type: RetType = RetType.JSON,
67-
query_params: typing.Dict[str, typing.Any] = None,
68+
query_params: Optional[typing.Dict[str, typing.Any]] = None,
6869
) -> typing.Union[http.client.HTTPResponse, bytes, str, None]:
6970
rest_uri = '/rest' + uri
7071
if req_type in ReqType:

test/functional/p2p_message_capture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
LENGTH_SIZE = 4
2020
MSGTYPE_SIZE = 12
2121

22-
def mini_parser(dat_file):
22+
def mini_parser(dat_file: str) -> None:
2323
"""Parse a data file created by CaptureMessageToFile.
2424
2525
From the data file we'll only check the structure.

test/functional/test_framework/coverage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import os
1212

1313
from .authproxy import AuthServiceProxy
14+
from typing import Optional
1415

1516
REFERENCE_FILENAME = 'rpc_interface.txt'
1617

@@ -20,7 +21,7 @@ class AuthServiceProxyWrapper():
2021
An object that wraps AuthServiceProxy to record specific RPC calls.
2122
2223
"""
23-
def __init__(self, auth_service_proxy_instance: AuthServiceProxy, rpc_url: str, coverage_logfile: str=None):
24+
def __init__(self, auth_service_proxy_instance: AuthServiceProxy, rpc_url: str, coverage_logfile: Optional[str]=None):
2425
"""
2526
Kwargs:
2627
auth_service_proxy_instance: the instance being wrapped.

test/functional/test_framework/test_framework.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
9292
9393
This class also contains various public and private helper methods."""
9494

95-
def __init__(self):
95+
def __init__(self) -> None:
9696
"""Sets test framework defaults. Do not override this method. Instead, override the set_test_params() method"""
9797
self.chain: str = 'regtest'
9898
self.setup_clean_chain: bool = False

test/functional/test_framework/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ class PortSeed:
309309
n = None
310310

311311

312-
def get_rpc_proxy(url: str, node_number: int, *, timeout: int=None, coveragedir: str=None) -> coverage.AuthServiceProxyWrapper:
312+
def get_rpc_proxy(url: str, node_number: int, *, timeout: Optional[int]=None, coveragedir: Optional[str]=None) -> coverage.AuthServiceProxyWrapper:
313313
"""
314314
Args:
315315
url: URL of the RPC server to call

test/lint/spelling.ignore-words.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
afile
12
asend
23
ba
34
blockin
@@ -15,6 +16,7 @@ lief
1516
mor
1617
nd
1718
nin
19+
requestor
1820
ser
1921
siz
2022
stap

0 commit comments

Comments
 (0)