Skip to content

Commit d196348

Browse files
committed
Avoid disabling some pylint checks when unnecessary
Signed-off-by: Leandro Lucarella <[email protected]>
1 parent d6f843a commit d196348

File tree

9 files changed

+13
-26
lines changed

9 files changed

+13
-26
lines changed

benchmarks/power_distribution/power_distributor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ async def run_test( # pylint: disable=too-many-locals
137137

138138
async def run() -> None:
139139
"""Create microgrid api and run tests."""
140-
# pylint: disable=protected-access
141-
142140
await microgrid.initialize(
143141
"grpc://microgrid.sandbox.api.frequenz.io:62060",
144142
ResamplerConfig(resampling_period=timedelta(seconds=1.0)),

benchmarks/timeseries/benchmark_datasourcing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ def enable_mock_client(client: MockMicrogridClient) -> None:
4949
Args:
5050
client: the mock microgrid client to enable.
5151
"""
52-
# pylint: disable=protected-access
53-
microgrid.connection_manager._CONNECTION_MANAGER = client.mock_microgrid
52+
microgrid.connection_manager._CONNECTION_MANAGER = ( # pylint: disable=protected-access
53+
client.mock_microgrid
54+
)
5455

5556

56-
# pylint: disable=too-many-locals
57-
async def benchmark_data_sourcing(
57+
async def benchmark_data_sourcing( # pylint: disable=too-many-locals
5858
num_ev_chargers: int, num_msgs_per_battery: int
5959
) -> None:
6060
"""Benchmark the data sourcing actor.

src/frequenz/sdk/actor/power_distributing/_component_status/_battery_status_tracker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ def _is_inverter_state_correct(self, msg: InverterData) -> bool:
398398
state.name,
399399
)
400400
return False
401+
# pylint: enable=protected-access
401402
return True
402403

403404
def _is_battery_state_correct(self, msg: BatteryData) -> bool:
@@ -422,7 +423,6 @@ def _is_battery_state_correct(self, msg: BatteryData) -> bool:
422423
return False
423424

424425
# Component state is not exposed to the user.
425-
# pylint: disable=protected-access
426426
relay_state = msg.relay_state
427427
if relay_state not in BatteryStatusTracker._battery_valid_relay:
428428
if self._last_status == ComponentStatusEnum.WORKING:
@@ -433,6 +433,7 @@ def _is_battery_state_correct(self, msg: BatteryData) -> bool:
433433
)
434434
return False
435435
return True
436+
# pylint: enable=protected-access
436437

437438
def _is_timestamp_outdated(self, timestamp: datetime) -> bool:
438439
"""Return if timestamp is to old.

src/frequenz/sdk/microgrid/component_graph.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,11 +1037,12 @@ def _correct_graph_errors(graph: _MicrogridComponentGraph) -> None:
10371037
# This is an expected case from the API: that no explicit
10381038
# grid endpoint will be provided, but that components connected
10391039
# to the grid endpoint will have node 0 as their predecessor.
1040+
# pylint: disable=protected-access
10401041
if (
1041-
graph._graph.has_node(0) # pylint: disable=protected-access
1042-
and graph._graph.in_degree(0) == 0 # pylint: disable=protected-access
1043-
and graph._graph.out_degree(0) > 0 # pylint: disable=protected-access
1044-
and "type" not in graph._graph.nodes[0] # pylint: disable=protected-access
1042+
graph._graph.has_node(0)
1043+
and graph._graph.in_degree(0) == 0
1044+
and graph._graph.out_degree(0) > 0
1045+
and "type" not in graph._graph.nodes[0]
10451046
):
1046-
# pylint: disable=protected-access
10471047
graph._graph.add_node(0, **asdict(Component(0, ComponentCategory.GRID)))
1048+
# pylint: enable=protected-access

tests/actor/test_config_manager.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
import pytest
88
from frequenz.channels import Broadcast
9-
10-
# pylint: disable = no-name-in-module
119
from pydantic import BaseModel
1210

1311
from frequenz.sdk.actor import ConfigManagingActor

tests/timeseries/test_resampling.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ async def test_calculate_window_end_trivial_cases(
253253
# pylint: disable=protected-access
254254
none_result = resampler_none._calculate_window_end()
255255
assert resampler_now._calculate_window_end() == none_result
256-
# pylint: disable=protected-access
257256
assert none_result[0] == now + resampling_period
258257

259258

tests/timeseries/test_ringbuffer.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ def test_timestamp_ringbuffer_missing_parameter(
166166
"""Test ordered ring buffer."""
167167
buffer.update(Sample(datetime(2, 2, 2, 0, 0, tzinfo=timezone.utc), Quantity(0)))
168168

169-
# pylint: disable=protected-access
170169
assert buffer.normalize_timestamp(buffer.gaps[0].start) == buffer.gaps[0].start
171170

172171
# Expecting one gap now, made of all the previous entries of the one just
@@ -175,7 +174,6 @@ def test_timestamp_ringbuffer_missing_parameter(
175174
assert buffer.gaps[0].end == datetime(2, 2, 2, tzinfo=timezone.utc)
176175

177176
# Add entry so that a second gap appears
178-
# pylint: disable=protected-access
179177
assert buffer.normalize_timestamp(
180178
datetime(2, 2, 2, 0, 7, 31, tzinfo=timezone.utc)
181179
) == datetime(2, 2, 2, 0, 10, tzinfo=timezone.utc)
@@ -333,11 +331,9 @@ def test_timestamp_ringbuffer_missing_parameter_smoke(
333331
expected_gaps = list(
334332
map(
335333
lambda x: Gap(
336-
# pylint: disable=protected-access
337334
start=buffer.normalize_timestamp(
338335
datetime.fromtimestamp(200 + x[0] * resolution, tz=timezone.utc)
339336
),
340-
# pylint: disable=protected-access
341337
end=buffer.normalize_timestamp(
342338
datetime.fromtimestamp(200 + x[1] * resolution, tz=timezone.utc)
343339
),

tests/timeseries/test_ringbuffer_serialization.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,17 @@ def load_dump_test(dumped: rb.OrderedRingBuffer[Any], path: str) -> None:
4545
rb.dump(dumped, path)
4646

4747
# Load old data
48-
# pylint: disable=protected-access
4948
loaded = rb.load(path)
5049
assert loaded is not None
5150

5251
np.testing.assert_equal(dumped[:], loaded[:])
5352

5453
# pylint: disable=protected-access
5554
assert dumped._timestamp_oldest == loaded._timestamp_oldest
56-
# pylint: disable=protected-access
5755
assert dumped._timestamp_newest == loaded._timestamp_newest
58-
# pylint: disable=protected-access
5956
assert len(dumped._gaps) == len(loaded._gaps)
60-
# pylint: disable=protected-access
6157
assert dumped._gaps == loaded._gaps
62-
# pylint: disable=protected-access
6358
assert dumped._sampling_period == loaded._sampling_period
64-
# pylint: disable=protected-access
6559
assert dumped._time_index_alignment == loaded._time_index_alignment
6660

6761

tests/utils/component_data_wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def copy_with_new_timestamp(self, new_timestamp: datetime) -> BatteryDataWrapper
9292
class InverterDataWrapper(InverterData):
9393
"""Wrapper for the InverterData with default arguments."""
9494

95-
def __init__( # pylint: disable=too-many-arguments
95+
def __init__( # pylint: disable=too-many-arguments,too-many-locals
9696
self,
9797
component_id: int,
9898
timestamp: datetime,

0 commit comments

Comments
 (0)