Skip to content

Commit c8c0f63

Browse files
committed
pylint: Don't disable check for the whole file
Also use `disable-next` instead of disabling blocks, as it is less error prone. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 35f4dce commit c8c0f63

File tree

8 files changed

+19
-21
lines changed

8 files changed

+19
-21
lines changed

examples/battery_pool.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ async def main() -> None:
3333
receivers = [
3434
battery_pool.soc.new_receiver(limit=1),
3535
battery_pool.capacity.new_receiver(limit=1),
36-
# pylint: disable=protected-access
36+
# pylint: disable-next=protected-access
3737
battery_pool._system_power_bounds.new_receiver(limit=1),
38-
# pylint: enable=protected-access
3938
]
4039

4140
async for metric in merge(*receivers):

src/frequenz/sdk/microgrid/_power_distributing/_component_status/_battery_status_tracker.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ def _is_inverter_state_correct(self, msg: InverterData) -> bool:
394394
True if inverter is in correct state. False otherwise.
395395
"""
396396
# Component state is not exposed to the user.
397-
# pylint: disable=protected-access
398397
state = msg.component_state
398+
# pylint: disable-next=protected-access
399399
if state not in BatteryStatusTracker._inverter_valid_state:
400400
if self._last_status == ComponentStatusEnum.WORKING:
401401
_logger.warning(
@@ -404,7 +404,6 @@ def _is_inverter_state_correct(self, msg: InverterData) -> bool:
404404
state.name,
405405
)
406406
return False
407-
# pylint: enable=protected-access
408407
return True
409408

410409
def _is_battery_state_correct(self, msg: BatteryData) -> bool:
@@ -417,8 +416,8 @@ def _is_battery_state_correct(self, msg: BatteryData) -> bool:
417416
True if battery is in correct state. False otherwise.
418417
"""
419418
# Component state is not exposed to the user.
420-
# pylint: disable=protected-access
421419
state = msg.component_state
420+
# pylint: disable-next=protected-access
422421
if state not in BatteryStatusTracker._battery_valid_state:
423422
if self._last_status == ComponentStatusEnum.WORKING:
424423
_logger.warning(
@@ -439,7 +438,6 @@ def _is_battery_state_correct(self, msg: BatteryData) -> bool:
439438
)
440439
return False
441440
return True
442-
# pylint: enable=protected-access
443441

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

src/frequenz/sdk/microgrid/_power_distributing/_distribution_algorithm/_battery_distribution_algorithm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ def _compute_battery_availability_ratio(
461461

462462
return battery_availability_ratio, total_battery_availability_ratio
463463

464-
def _distribute_power( # pylint: disable=too-many-arguments
464+
# pylint: disable-next=too-many-arguments,too-many-locals,too-many-branches,too-many-statements
465+
def _distribute_power(
465466
self,
466467
*,
467468
components: list[InvBatPair],
@@ -470,7 +471,6 @@ def _distribute_power( # pylint: disable=too-many-arguments
470471
incl_bounds: dict[ComponentId, Power],
471472
excl_bounds: dict[ComponentId, Power],
472473
) -> DistributionResult:
473-
# pylint: disable=too-many-locals,too-many-branches,too-many-statements
474474
"""Distribute power between given components.
475475
476476
After this method power should be distributed between batteries

src/frequenz/sdk/microgrid/_power_distributing/power_distributing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
_logger = logging.getLogger(__name__)
3434

3535

36-
class PowerDistributingActor(Actor):
37-
# pylint: disable=too-many-instance-attributes
36+
class PowerDistributingActor(Actor): # pylint: disable=too-many-instance-attributes
3837
"""Actor to distribute the power between components in a microgrid.
3938
4039
One instance of the actor can handle only one component category and type,

src/frequenz/sdk/microgrid/_power_managing/_power_managing_actor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,17 @@ def _add_system_bounds_tracker(self, component_ids: frozenset[ComponentId]) -> N
158158
NotImplementedError: When the pool type is not supported.
159159
"""
160160
bounds_receiver: Receiver[SystemBounds]
161-
# pylint: disable=protected-access
162161
if self._component_category is ComponentCategory.BATTERY:
163162
battery_pool = _data_pipeline.new_battery_pool(
164163
priority=-sys.maxsize - 1, component_ids=component_ids
165164
)
165+
# pylint: disable-next=protected-access
166166
bounds_receiver = battery_pool._system_power_bounds.new_receiver()
167167
elif self._component_category is ComponentCategory.EV_CHARGER:
168168
ev_charger_pool = _data_pipeline.new_ev_charger_pool(
169169
priority=-sys.maxsize - 1, component_ids=component_ids
170170
)
171+
# pylint: disable-next=protected-access
171172
bounds_receiver = ev_charger_pool._system_power_bounds.new_receiver()
172173
elif (
173174
self._component_category is ComponentCategory.INVERTER
@@ -176,8 +177,8 @@ def _add_system_bounds_tracker(self, component_ids: frozenset[ComponentId]) -> N
176177
pv_pool = _data_pipeline.new_pv_pool(
177178
priority=-sys.maxsize - 1, component_ids=component_ids
178179
)
180+
# pylint: disable-next=protected-access
179181
bounds_receiver = pv_pool._system_power_bounds.new_receiver()
180-
# pylint: enable=protected-access
181182
else:
182183
err = (
183184
"PowerManagingActor: Unsupported component category: "

src/frequenz/sdk/microgrid/_power_wrapper.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
from datetime import timedelta
1010

1111
from frequenz.channels import Broadcast
12-
13-
# pylint seems to think this is a cyclic import, but it is not.
14-
#
15-
# pylint: disable=cyclic-import
1612
from frequenz.client.microgrid import ComponentCategory, ComponentType
1713

1814
from .._internal._channels import ChannelRegistry, ReceiverFetcher
15+
16+
# pylint seems to think this is a cyclic import, but it is not.
17+
#
18+
# pylint: disable-next=cyclic-import
1919
from . import _power_managing, connection_manager
20+
21+
# pylint: disable-next=cyclic-import
2022
from ._power_distributing import (
2123
ComponentPoolStatus,
2224
PowerDistributingActor,

src/frequenz/sdk/timeseries/_resampling/_config.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@ def __call__(
8080
... # pylint: disable=unnecessary-ellipsis
8181

8282

83-
# pylint: disable=unused-argument
8483
def average(
8584
samples: Sequence[Sample[QuantityT]],
86-
resampler_config: ResamplerConfig,
87-
source_properties: SourceProperties,
85+
resampler_config: ResamplerConfig, # pylint: disable=unused-argument
86+
source_properties: SourceProperties, # pylint: disable=unused-argument
8887
) -> float:
8988
"""Calculate average of all the provided values.
9089

src/frequenz/sdk/timeseries/battery_pool/_component_metric_fetcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ async def async_new(
104104
"""
105105
self: Self = await super().async_new(component_id, metrics)
106106

107+
# pylint: disable=protected-access
107108
for metric in metrics:
108-
# pylint: disable=protected-access
109109
if metric not in self._supported_metrics():
110110
category = self._component_category()
111111
raise ValueError(f"Metric {metric} not supported for {category}")
112112

113-
# pylint: disable=protected-access
114113
self._receiver = await self._subscribe()
115114
self._max_waiting_time = MAX_BATTERY_DATA_AGE_SEC
115+
# pylint: enable=protected-access
116116
return self
117117

118118
async def fetch_next(self) -> ComponentMetricsData | None:

0 commit comments

Comments
 (0)