Skip to content

Commit 4170736

Browse files
Update pylint mypy (#446)
1 parent 5dd7c53 commit 4170736

File tree

8 files changed

+196
-192
lines changed

8 files changed

+196
-192
lines changed

poetry.lock

Lines changed: 178 additions & 178 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ python-json-logger = "==2.0.7"
2525
aiohttp = "==3.10.11"
2626

2727
[tool.poetry.group.dev.dependencies]
28-
pylint = "==3.0.1"
29-
mypy = "==1.6.1"
28+
pylint = "==3.3.3"
29+
mypy = "==1.14.1"
3030
isort = "==5.12.0"
3131
pytest = "==7.4.2"
3232
pytest-asyncio = "==0.21.1"
@@ -64,7 +64,8 @@ disable = [
6464
"C0115", # missing-class-docstring
6565
"C0116", # missing-function-docstring
6666
"R0801", # duplicate-code
67-
"R0903" # too-few-public-methods
67+
"R0903", # too-few-public-methods
68+
"R0917" # Too many positional arguments
6869
]
6970
ignore-paths=["src/.*/tests/.*", "src/test_fixtures/.*"]
7071
ignore=["conftest.py"]

src/common/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def warning_verbose(msg: str, *args) -> None: # type: ignore
4747
logger.warning(msg, *args)
4848

4949

50-
def format_error(e: Exception) -> str:
50+
def format_error(e: BaseException) -> str:
5151
if isinstance(e, tenacity.RetryError):
5252
# get original error
5353
e = e.last_attempt.exception() # type: ignore

src/exits/tasks.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ async def _fetch_last_update_block_replicas(replicas: list[str]) -> BlockNumber
9090
results = await asyncio.gather(
9191
*[_fetch_exit_signature_block(endpoint) for endpoint in replicas], return_exceptions=True
9292
)
93-
blocks = []
93+
blocks: list[BlockNumber] = []
9494
for res in results:
95-
if not isinstance(res, Exception) and res is not None:
95+
if not isinstance(res, BaseException) and res is not None:
9696
blocks.append(res)
9797
if blocks:
9898
return min(blocks)
@@ -153,14 +153,15 @@ async def _update_exit_signatures(
153153
logger.info('Starting exit signature rotation for %d validators', len(outdated_indexes))
154154
# pylint: disable=duplicate-code
155155
validators = await get_validator_public_keys(outdated_indexes)
156-
deadline = None
157156
approvals_min_interval = 1
157+
deadline: int | None = None
158+
oracles_request: SignatureRotationRequest | None = None
158159

159160
while True:
160161
approval_start_time = time.time()
161162

162163
current_timestamp = get_current_timestamp()
163-
if not deadline or deadline <= current_timestamp:
164+
if not oracles_request or deadline is None or deadline <= current_timestamp:
164165
deadline = current_timestamp + protocol_config.signature_validity_period
165166
oracles_request = await _get_oracles_request(
166167
protocol_config=protocol_config,

src/exits/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async def send_signature_rotation_requests(
4545
return_exceptions=True,
4646
)
4747
for (address, replicas), result in zip(endpoints, results):
48-
if isinstance(result, Exception):
48+
if isinstance(result, BaseException):
4949
warning_verbose(
5050
'All endpoints for oracle %s failed to sign signature rotation request. '
5151
'Last error: %s',

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def cli() -> None:
5959
multiprocessing.freeze_support()
6060
# Use certificate from certifi only if cafile could not find by ssl.
6161
if ssl.get_default_verify_paths().cafile is None and hasattr(sys, '_MEIPASS'):
62-
# pylint: disable-next=protected-access
62+
# pylint: disable-next=protected-access,no-member
6363
os.environ['SSL_CERT_FILE'] = os.path.join(sys._MEIPASS, 'certifi', 'cacert.pem')
6464

6565
cli()

src/validators/signing/key_shares.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import secrets
2-
from typing import TypeAlias
2+
from typing import TypeAlias, cast
33

44
from eth_typing import BLSPubkey, BLSSignature
55
from py_ecc.bls import G2ProofOfPossession
@@ -9,7 +9,7 @@
99
pubkey_to_G1,
1010
signature_to_G2,
1111
)
12-
from py_ecc.bls.hash_to_curve import hash_to_G2
12+
from py_ecc.bls.hash_to_curve import HASH, hash_to_G2
1313
from py_ecc.optimized_bls12_381.optimized_curve import (
1414
G1 as P1, # don't confuse group name (G1) with primitive element name (P1)
1515
)
@@ -30,7 +30,9 @@ def bls_signature_and_public_key_to_shares(
3030
The function splits `signature` and `public_key` to shares so that
3131
each signature share can be verified with corresponding public key share.
3232
"""
33-
message_g2 = hash_to_G2(message, G2ProofOfPossession.DST, G2ProofOfPossession.xmd_hash_function)
33+
message_g2 = hash_to_G2(
34+
message, G2ProofOfPossession.DST, cast(HASH, G2ProofOfPossession.xmd_hash_function)
35+
)
3436

3537
coefficients_int = [secrets.randbelow(curve_order) for _ in range(threshold - 1)]
3638
coefficients_G1 = [multiply(P1, coef) for coef in coefficients_int]

src/validators/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async def send_approval_requests(
5151
failed_endpoints: list[str] = []
5252

5353
for (address, replicas), result in zip(endpoints, results):
54-
if isinstance(result, Exception):
54+
if isinstance(result, BaseException):
5555
warning_verbose(
5656
'All endpoints for oracle %s failed to sign validators approval request. '
5757
'Last error: %s',

0 commit comments

Comments
 (0)