Skip to content

Commit 03665b2

Browse files
committed
fix: linter
1 parent 4435d79 commit 03665b2

File tree

12 files changed

+41
-34
lines changed

12 files changed

+41
-34
lines changed

src/constants.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from packaging.version import Version
22

33
from src.types import Gwei
4-
from src.variables import STAKING_MODULE_ADDRESS
5-
64
# https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#misc
75
FAR_FUTURE_EPOCH = 2**64 - 1
86
# https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#time-parameters-1

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
def main(module: OracleModule):
15-
# pylint: disable=import-outside-toplevel
15+
# pylint: disable=import-outside-toplevel,too-many-return-statements
1616

1717
if module is OracleModule.CHECK:
1818
errors = variables.check_uri_required_variables()

src/modules/checks/suites/common.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,3 @@ def check_csm_contract_configs(csm):
6363
def check_cm_contract_configs(cm):
6464
"""Make sure cm contract configs are valid"""
6565
cm.check_contract_configs()
66-

src/modules/oracles/common/oracle_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def run_cycle(self, last_finalized_blockstamp: BlockStamp):
4949

5050
@contextmanager
5151
def exception_handler(self) -> Iterator[None]:
52+
# pylint: disable=too-many-branches
5253
"""Context manager for handling Oracle module cycle exceptions"""
5354
try:
5455
yield
@@ -86,7 +87,6 @@ def exception_handler(self) -> Iterator[None]:
8687
except ValueError as error:
8788
logger.error({'msg': 'Unexpected error.', 'error': str(error)})
8889
except Exception as error:
89-
# Перебрасываем неизвестные исключения
9090
raise error
9191

9292
@abstractmethod

src/modules/oracles/staking_modules/base.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import atexit
22
import logging
3-
from abc import abstractmethod
43

54
from hexbytes import HexBytes
65

@@ -55,22 +54,17 @@ class SMPerformanceOracle(OracleModule):
5554
3. Calculate the share of each node operator excluding underperforming validators.
5655
"""
5756

58-
@property
59-
@abstractmethod
60-
def COMPATIBLE_CONTRACT_VERSION(self) -> int:
61-
"""Contract version this oracle is compatible with"""
62-
raise NotImplementedError
63-
64-
@property
65-
@abstractmethod
66-
def COMPATIBLE_CONSENSUS_VERSION(self) -> int:
67-
"""Consensus version this oracle is compatible with"""
68-
raise NotImplementedError
57+
COMPATIBLE_CONTRACT_VERSION: int = 0
58+
COMPATIBLE_CONSENSUS_VERSION: int = 0
6959

7060
report_contract: CSFeeOracleContract
7161
state: State
7262

7363
def __init__(self, w3: Web3):
64+
if self.COMPATIBLE_CONTRACT_VERSION == 0:
65+
raise ValueError("CONTRACT_VERSION is not defined")
66+
if self.COMPATIBLE_CONSENSUS_VERSION == 0:
67+
raise ValueError("CONSENSUS_VERSION is not defined")
7468
self.consumer = self.__class__.__name__
7569
self.report_contract = w3.staking_module.oracle
7670
self.state = State.load(self.consumer)

src/modules/oracles/staking_modules/common/state.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ def load(cls, oracle_name: str) -> Self:
118118
if not obj:
119119
raise ValueError("Got empty object")
120120
# Ensure loaded object has the correct oracle_name
121-
if hasattr(obj, "_oracle_name") and obj._oracle_name != oracle_name:
121+
# pylint: disable=protected-access
122+
if obj._oracle_name != oracle_name:
122123
logger.warning({
123124
"msg": f"Cache oracle name mismatch: {obj._oracle_name} != {oracle_name}. Creating new state."
124125
})

src/web3py/extensions/staking_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,4 @@ def has_contract_address_changed(self) -> bool:
161161
return False
162162

163163
def reload_contracts(self) -> None:
164-
self._load_contracts()
164+
self._load_contracts()

tests/fork/test_csm_oracle_cycle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,16 @@ def missed_initial_frame(frame_config: FrameConfig, cycle_iterations):
100100
'module',
101101
[
102102
csm_module,
103-
#cm_module
103+
# cm_module
104104
],
105105
indirect=True,
106106
)
107107
@pytest.mark.parametrize(
108108
'running_finalized_slots',
109109
[
110-
#start_before_initial_epoch,
110+
# start_before_initial_epoch,
111111
start_after_initial_epoch,
112-
#missed_initial_frame
112+
# missed_initial_frame
113113
],
114114
indirect=True,
115115
)

tests/modules/csm/test_csm_distribution.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
MIN_ACTIVATION_BALANCE,
1313
EFFECTIVE_BALANCE_INCREMENT,
1414
)
15-
from src.modules.oracles.staking_modules.common.distribution import Distribution, ValidatorDuties, ValidatorDutiesOutcome
15+
from src.modules.oracles.staking_modules.common.distribution import (
16+
Distribution,
17+
ValidatorDuties,
18+
ValidatorDutiesOutcome,
19+
)
1620
from src.modules.oracles.staking_modules.common.log import FramePerfLog, ValidatorFrameSummary, OperatorFrameSummary
1721
from src.modules.oracles.staking_modules.common.state import DutyAccumulator, State, NetworkDuties, Frame
1822
from src.modules.oracles.staking_modules.common.types import StrikesList
@@ -297,7 +301,9 @@ def test_calculate_distribution(
297301
expected_strikes,
298302
):
299303
# Mocking the data from EL
300-
w3 = Mock(spec=Web3, staking_module=Mock(spec=StakingModuleContracts, fee_distributor=Mock(spec=CSFeeDistributorContract)))
304+
w3 = Mock(
305+
spec=Web3, staking_module=Mock(spec=StakingModuleContracts, fee_distributor=Mock(spec=CSFeeDistributorContract))
306+
)
301307
w3.staking_module.fee_distributor.shares_to_distribute = Mock(side_effect=shares_to_distribute)
302308
w3.staking_module.get_curve_params = mocked_curve_params
303309

@@ -323,7 +329,9 @@ def test_calculate_distribution(
323329
@pytest.mark.unit
324330
def test_calculate_distribution_handles_invalid_distribution():
325331
# Mocking the data from EL
326-
w3 = Mock(spec=Web3, staking_module=Mock(spec=StakingModuleContracts, fee_distributor=Mock(spec=CSFeeDistributorContract)))
332+
w3 = Mock(
333+
spec=Web3, staking_module=Mock(spec=StakingModuleContracts, fee_distributor=Mock(spec=CSFeeDistributorContract))
334+
)
327335
w3.staking_module.fee_distributor.shares_to_distribute = Mock(return_value=500)
328336
w3.staking_module.get_curve_params = Mock(...)
329337

@@ -351,7 +359,9 @@ def test_calculate_distribution_handles_invalid_distribution():
351359
@pytest.mark.unit
352360
def test_calculate_distribution_handles_invalid_distribution_in_total():
353361
# Mocking the data from EL
354-
w3 = Mock(spec=Web3, staking_module=Mock(spec=StakingModuleContracts, fee_distributor=Mock(spec=CSFeeDistributorContract)))
362+
w3 = Mock(
363+
spec=Web3, staking_module=Mock(spec=StakingModuleContracts, fee_distributor=Mock(spec=CSFeeDistributorContract))
364+
)
355365
w3.staking_module.fee_distributor.shares_to_distribute = Mock(return_value=500)
356366
w3.staking_module.get_curve_params = Mock(...)
357367

tests/modules/csm/test_csm_module.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ def test_set_epochs_range_to_collect_posts_new_demand(module: CSPerformanceOracl
270270

271271

272272
@pytest.mark.unit
273-
def test_set_epochs_range_to_collect_skips_post_when_demand_same(module: CSPerformanceOracle, mock_chain_config: NoReturn):
273+
def test_set_epochs_range_to_collect_skips_post_when_demand_same(
274+
module: CSPerformanceOracle, mock_chain_config: NoReturn
275+
):
274276
blockstamp = ReferenceBlockStampFactory.build()
275277
module.state = Mock(migrate=Mock(), log_progress=Mock())
276278
converter = Mock()

0 commit comments

Comments
 (0)