Merge bitcoin/bitcoin#28009: script, test: python typing and linter updates

6c97757a48 script: appease spelling linter (Jon Atack)
1316119ce7 script: update ignored-words.txt (Jon Atack)
146c861da2 script: update linter dependencies (Jon Atack)
92408224a4 test: fix PEP484 no implicit optional argument types errors (Jon Atack)
f86a301433 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 6c97757a48

Tree-SHA512: 8a46a4d36d5978affdcecf4f2ace20ca1b52d483e098304911a2169afe60ccb9b042fa90c04b762d94f3ce53d2cafe6f24476ae839867a770c7f31e7e7242d99
This commit is contained in:
fanquake 2023-06-30 16:19:16 +01:00
commit 3367e1c850
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1
10 changed files with 18 additions and 14 deletions

View file

@ -33,11 +33,11 @@ if [ -z "${SKIP_PYTHON_INSTALL}" ]; then
python3 --version python3 --version
fi fi
${CI_RETRY_EXE} pip3 install codespell==2.2.1 ${CI_RETRY_EXE} pip3 install codespell==2.2.5
${CI_RETRY_EXE} pip3 install flake8==5.0.4 ${CI_RETRY_EXE} pip3 install flake8==6.0.0
${CI_RETRY_EXE} pip3 install lief==0.13.1 ${CI_RETRY_EXE} pip3 install lief==0.13.2
${CI_RETRY_EXE} pip3 install mypy==0.971 ${CI_RETRY_EXE} pip3 install mypy==1.4.1
${CI_RETRY_EXE} pip3 install pyzmq==24.0.1 ${CI_RETRY_EXE} pip3 install pyzmq==25.1.0
${CI_RETRY_EXE} pip3 install vulture==2.6 ${CI_RETRY_EXE} pip3 install vulture==2.6
SHELLCHECK_VERSION=v0.8.0 SHELLCHECK_VERSION=v0.8.0

View file

@ -28,7 +28,7 @@ def clean_files(source, executable):
os.remove(source) os.remove(source)
os.remove(executable) os.remove(executable)
def call_security_check(cc, source, executable, options): def call_security_check(cc: str, source: str, executable: str, options) -> tuple:
# This should behave the same as AC_TRY_LINK, so arrange well-known flags # This should behave the same as AC_TRY_LINK, so arrange well-known flags
# in the same order as autoconf would. # in the same order as autoconf would.
# #

View file

@ -210,7 +210,7 @@ util::Result<std::unique_ptr<AddrMan>> LoadAddrman(const NetGroupManager& netgro
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."), 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."),
e.what(), PACKAGE_BUGREPORT, fs::quoted(fs::PathToString(path_addr)))}; e.what(), PACKAGE_BUGREPORT, fs::quoted(fs::PathToString(path_addr)))};
} }
return {std::move(addrman)}; // std::move should be unneccessary but is temporarily needed to work around clang bug return {std::move(addrman)}; // std::move should be unnecessary but is temporarily needed to work around clang bug
// (https://github.com/bitcoin/bitcoin/pull/25977#issuecomment-1561270092) // (https://github.com/bitcoin/bitcoin/pull/25977#issuecomment-1561270092)
} }

View file

@ -463,8 +463,8 @@ BOOST_FIXTURE_TEST_CASE(calculate_cluster, TestChain100Setup)
} }
const auto vec_iters_zigzag = pool.GetIterVec(zigzag_txids); const auto vec_iters_zigzag = pool.GetIterVec(zigzag_txids);
// It doesn't matter which tx we calculate cluster for, everybody is in it. // It doesn't matter which tx we calculate cluster for, everybody is in it.
const std::vector<size_t> indeces{0, 22, 72, zigzag_txids.size() - 1}; const std::vector<size_t> indices{0, 22, 72, zigzag_txids.size() - 1};
for (const auto index : indeces) { for (const auto index : indices) {
const auto cluster = pool.GatherClusters({zigzag_txids[index]}); const auto cluster = pool.GatherClusters({zigzag_txids[index]});
BOOST_CHECK_EQUAL(cluster.size(), zigzag_txids.size()); BOOST_CHECK_EQUAL(cluster.size(), zigzag_txids.size());
CTxMemPool::setEntries clusterset{cluster.begin(), cluster.end()}; CTxMemPool::setEntries clusterset{cluster.begin(), cluster.end()};

View file

@ -26,6 +26,7 @@ from test_framework.wallet import (
MiniWallet, MiniWallet,
getnewdestination, getnewdestination,
) )
from typing import Optional
INVALID_PARAM = "abc" INVALID_PARAM = "abc"
@ -64,7 +65,7 @@ class RESTTest (BitcoinTestFramework):
body: str = '', body: str = '',
status: int = 200, status: int = 200,
ret_type: RetType = RetType.JSON, ret_type: RetType = RetType.JSON,
query_params: typing.Dict[str, typing.Any] = None, query_params: Optional[typing.Dict[str, typing.Any]] = None,
) -> typing.Union[http.client.HTTPResponse, bytes, str, None]: ) -> typing.Union[http.client.HTTPResponse, bytes, str, None]:
rest_uri = '/rest' + uri rest_uri = '/rest' + uri
if req_type in ReqType: if req_type in ReqType:

View file

@ -19,7 +19,7 @@ TIME_SIZE = 8
LENGTH_SIZE = 4 LENGTH_SIZE = 4
MSGTYPE_SIZE = 12 MSGTYPE_SIZE = 12
def mini_parser(dat_file): def mini_parser(dat_file: str) -> None:
"""Parse a data file created by CaptureMessageToFile. """Parse a data file created by CaptureMessageToFile.
From the data file we'll only check the structure. From the data file we'll only check the structure.

View file

@ -11,6 +11,7 @@ testing.
import os import os
from .authproxy import AuthServiceProxy from .authproxy import AuthServiceProxy
from typing import Optional
REFERENCE_FILENAME = 'rpc_interface.txt' REFERENCE_FILENAME = 'rpc_interface.txt'
@ -20,7 +21,7 @@ class AuthServiceProxyWrapper():
An object that wraps AuthServiceProxy to record specific RPC calls. An object that wraps AuthServiceProxy to record specific RPC calls.
""" """
def __init__(self, auth_service_proxy_instance: AuthServiceProxy, rpc_url: str, coverage_logfile: str=None): def __init__(self, auth_service_proxy_instance: AuthServiceProxy, rpc_url: str, coverage_logfile: Optional[str]=None):
""" """
Kwargs: Kwargs:
auth_service_proxy_instance: the instance being wrapped. auth_service_proxy_instance: the instance being wrapped.

View file

@ -92,7 +92,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
This class also contains various public and private helper methods.""" This class also contains various public and private helper methods."""
def __init__(self): def __init__(self) -> None:
"""Sets test framework defaults. Do not override this method. Instead, override the set_test_params() method""" """Sets test framework defaults. Do not override this method. Instead, override the set_test_params() method"""
self.chain: str = 'regtest' self.chain: str = 'regtest'
self.setup_clean_chain: bool = False self.setup_clean_chain: bool = False

View file

@ -309,7 +309,7 @@ class PortSeed:
n = None n = None
def get_rpc_proxy(url: str, node_number: int, *, timeout: int=None, coveragedir: str=None) -> coverage.AuthServiceProxyWrapper: def get_rpc_proxy(url: str, node_number: int, *, timeout: Optional[int]=None, coveragedir: Optional[str]=None) -> coverage.AuthServiceProxyWrapper:
""" """
Args: Args:
url: URL of the RPC server to call url: URL of the RPC server to call

View file

@ -1,3 +1,4 @@
afile
asend asend
ba ba
blockin blockin
@ -15,6 +16,7 @@ lief
mor mor
nd nd
nin nin
requestor
ser ser
siz siz
stap stap