Skip to content

Commit 9240822

Browse files
committed
test: fix PEP484 no implicit optional argument types errors
Fix warnings for these files when ./test/lint/lint-python.py is run using mypy 0.991 (released 11/2022) and later: $ test/lint/lint-python.py test/functional/test_framework/coverage.py:23: error: Incompatible default for argument "coverage_logfile" (default has type "None", argument has type "str") [assignment] test/functional/test_framework/coverage.py:23: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True test/functional/test_framework/util.py:318: error: Incompatible default for argument "timeout" (default has type "None", argument has type "int") [assignment] test/functional/test_framework/util.py:318: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True test/functional/test_framework/util.py:318: error: Incompatible default for argument "coveragedir" (default has type "None", argument has type "str") [assignment] test/functional/interface_rest.py:67: error: Incompatible default for argument "query_params" (default has type "None", argument has type "dict[str, Any]") [assignment] test/functional/interface_rest.py:67: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True Verified using https://github.com/hauntsaninja/no_implicit_optional For details, see: https://mypy-lang.blogspot.com/2022/11/mypy-0990-released.html
1 parent f86a301 commit 9240822

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

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/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/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

0 commit comments

Comments
 (0)