Skip to content

Commit 048852f

Browse files
authored
Bump pylint from 3.3.8 to 4.0.4 (#1312)
Bumps [pylint](https://github.com/pylint-dev/pylint) from 3.3.8 to 4.0.4. <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/pylint-dev/pylint/commit/e16f942166511d6fb4427e503a734152fae0c4fe"><code>e16f942</code></a> Bump pylint to 4.0.4, update changelog</li> <li><a href="https://github.com/pylint-dev/pylint/commit/657b386c0a83202faa95c9a525b8feb80a4c11ab"><code>657b386</code></a> [Backport maintenance/4.0.x] [invalid-name] Fix FP for exclusive assignment o...</li> <li><a href="https://github.com/pylint-dev/pylint/commit/03f8a922a2eabe5b517457807cc992e122dcc9c0"><code>03f8a92</code></a> [Backport maintenance/4.0.x] fix: avoid false positive when module-level name...</li> <li><a href="https://github.com/pylint-dev/pylint/commit/84b6552b86e210097ac29de7ef64b152efb4a454"><code>84b6552</code></a> Bump pylint to 4.0.3, update changelog (<a href="https://redirect.github.com/pylint-dev/pylint/issues/10741">#10741</a>)</li> <li><a href="https://github.com/pylint-dev/pylint/commit/77b0cd8c0e40eb563ab96067be6bdb3e9e266f1e"><code>77b0cd8</code></a> [Backport maintenance/4.0.x] fix(expand_modules): pass ignore_list to modutil...</li> <li><a href="https://github.com/pylint-dev/pylint/commit/755f2d0327809a5b358b99ad7fc67a7a5a2faad0"><code>755f2d0</code></a> [Backport maintenance/4.0.x] Upgrade astroid to 4.0.2 (<a href="https://redirect.github.com/pylint-dev/pylint/issues/10733">#10733</a>)</li> <li><a href="https://github.com/pylint-dev/pylint/commit/c96a9e4d232abcfa1d7f449839b68337816305e9"><code>c96a9e4</code></a> [Backport maintenance/4.0.x] Fix crash when a variable annotation is used as ...</li> <li><a href="https://github.com/pylint-dev/pylint/commit/108191ebbcd9dc8fa9e3fb71c83fd247d2f6ccd1"><code>108191e</code></a> [Backport maintenance/4.0.x] Fix a false positive for class attribute typed w...</li> <li><a href="https://github.com/pylint-dev/pylint/commit/0ed81725382db48ac0061c96c1948f42fe75f85d"><code>0ed8172</code></a> [Backport maintenance/4.0.x] Fix crash when a <code>slice</code> object is called (<a href="https://redirect.github.com/pylint-dev/pylint/issues/10728">#10728</a>)</li> <li><a href="https://github.com/pylint-dev/pylint/commit/b128b7d909bf541b2978d84bfe5ed4f4d67210e5"><code>b128b7d</code></a> [Backport maintenance/4.0.x] Fix a false positive for ``unbalanced-tuple-unpa...</li> <li>Additional commits viewable in <a href="https://github.com/pylint-dev/pylint/compare/v3.3.8...v4.0.4">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pylint&package-manager=pip&previous-version=3.3.8&new-version=4.0.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details>
2 parents d07fa50 + bd720be commit 048852f

File tree

6 files changed

+44
-31
lines changed

6 files changed

+44
-31
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ dev-mypy = [
7777
]
7878
dev-noxfile = ["nox == 2025.11.12", "frequenz-repo-config[lib] == 0.13.8"]
7979
dev-pylint = [
80-
"pylint == 3.3.8",
80+
"pylint == 4.0.4",
8181
# For checking the noxfile, docs/ script, and tests
8282
"frequenz-sdk[dev-mkdocs,dev-noxfile,dev-pytest]",
8383
]

src/frequenz/sdk/microgrid/_data_sourcing/microgrid_api_source.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
_logger = logging.getLogger(__name__)
3131

32-
_MeterDataMethods: dict[Metric | TransitionalMetric, Callable[[MeterData], float]] = {
32+
_METER_DATA_METHODS: dict[Metric | TransitionalMetric, Callable[[MeterData], float]] = {
3333
Metric.AC_ACTIVE_POWER: lambda msg: msg.active_power,
3434
Metric.AC_ACTIVE_POWER_PHASE_1: lambda msg: msg.active_power_per_phase[0],
3535
Metric.AC_ACTIVE_POWER_PHASE_2: lambda msg: msg.active_power_per_phase[1],
@@ -47,7 +47,7 @@
4747
Metric.AC_REACTIVE_POWER_PHASE_3: lambda msg: msg.reactive_power_per_phase[2],
4848
}
4949

50-
_BatteryDataMethods: dict[
50+
_BATTERY_DATA_METHODS: dict[
5151
Metric | TransitionalMetric, Callable[[BatteryData], float]
5252
] = {
5353
Metric.BATTERY_SOC_PCT: lambda msg: msg.soc,
@@ -69,7 +69,7 @@
6969
Metric.BATTERY_TEMPERATURE: lambda msg: msg.temperature,
7070
}
7171

72-
_InverterDataMethods: dict[
72+
_INVERTER_DATA_METHODS: dict[
7373
Metric | TransitionalMetric, Callable[[InverterData], float]
7474
] = {
7575
Metric.AC_ACTIVE_POWER: lambda msg: msg.active_power,
@@ -101,7 +101,7 @@
101101
Metric.AC_REACTIVE_POWER_PHASE_3: lambda msg: msg.reactive_power_per_phase[2],
102102
}
103103

104-
_EVChargerDataMethods: dict[
104+
_EV_CHARGER_DATA_METHODS: dict[
105105
Metric | TransitionalMetric, Callable[[EVChargerData], float]
106106
] = {
107107
Metric.AC_ACTIVE_POWER: lambda msg: msg.active_power,
@@ -191,7 +191,7 @@ async def _check_battery_request(
191191
for the given battery.
192192
"""
193193
for metric in requests:
194-
if metric not in _BatteryDataMethods:
194+
if metric not in _BATTERY_DATA_METHODS:
195195
err = f"Unknown metric {metric} for Battery id {comp_id}"
196196
_logger.error(err)
197197
raise ValueError(err)
@@ -216,7 +216,7 @@ async def _check_ev_charger_request(
216216
for the given EV Charger.
217217
"""
218218
for metric in requests:
219-
if metric not in _EVChargerDataMethods:
219+
if metric not in _EV_CHARGER_DATA_METHODS:
220220
err = f"Unknown metric {metric} for EvCharger id {comp_id}"
221221
_logger.error(err)
222222
raise ValueError(err)
@@ -241,7 +241,7 @@ async def _check_inverter_request(
241241
for the given inverter.
242242
"""
243243
for metric in requests:
244-
if metric not in _InverterDataMethods:
244+
if metric not in _INVERTER_DATA_METHODS:
245245
err = f"Unknown metric {metric} for Inverter id {comp_id}"
246246
_logger.error(err)
247247
raise ValueError(err)
@@ -266,7 +266,7 @@ async def _check_meter_request(
266266
for the given meter.
267267
"""
268268
for metric in requests:
269-
if metric not in _MeterDataMethods:
269+
if metric not in _METER_DATA_METHODS:
270270
err = f"Unknown metric {metric} for Meter id {comp_id}"
271271
_logger.error(err)
272272
raise ValueError(err)
@@ -326,13 +326,13 @@ def _get_data_extraction_method(
326326
representing the given metric.
327327
"""
328328
if category == ComponentCategory.BATTERY:
329-
return _BatteryDataMethods[metric]
329+
return _BATTERY_DATA_METHODS[metric]
330330
if category == ComponentCategory.INVERTER:
331-
return _InverterDataMethods[metric]
331+
return _INVERTER_DATA_METHODS[metric]
332332
if category == ComponentCategory.METER:
333-
return _MeterDataMethods[metric]
333+
return _METER_DATA_METHODS[metric]
334334
if category == ComponentCategory.EV_CHARGER:
335-
return _EVChargerDataMethods[metric]
335+
return _EV_CHARGER_DATA_METHODS[metric]
336336
err = f"Unknown component category {category}"
337337
_logger.error(err)
338338
raise ValueError(err)

src/frequenz/sdk/microgrid/_old_component_data.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ class MeterData(ComponentData):
295295

296296
@override
297297
@classmethod
298+
# pylint: disable-next=too-many-branches
298299
def from_samples(cls, samples: ComponentDataSamples) -> Self:
299300
"""Create a new instance from a component data object."""
300301
if not samples.metric_samples:
@@ -700,6 +701,7 @@ class InverterData(ComponentData): # pylint: disable=too-many-instance-attribut
700701

701702
@override
702703
@classmethod
704+
# pylint: disable-next=too-many-branches
703705
def from_samples(cls, samples: ComponentDataSamples) -> Self:
704706
"""Create a new instance from a component data object."""
705707
if not samples.metric_samples:
@@ -962,6 +964,7 @@ class EVChargerData(ComponentData): # pylint: disable=too-many-instance-attribu
962964

963965
@override
964966
@classmethod
967+
# pylint: disable-next=too-many-branches
965968
def from_samples(cls, samples: ComponentDataSamples) -> Self:
966969
"""Create a new instance from a component data object."""
967970
if not samples.metric_samples:

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

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,7 @@ def calculate_target_power(
181181
if not self._validate_component_ids(component_ids, proposal, system_bounds):
182182
return None
183183

184-
if proposal is not None:
185-
bucket = self._component_buckets.setdefault(component_ids, set())
186-
if proposal in bucket:
187-
bucket.remove(proposal)
188-
if (
189-
proposal.preferred_power is not None
190-
or proposal.bounds.lower is not None
191-
or proposal.bounds.upper is not None
192-
):
193-
bucket.add(proposal)
194-
elif not bucket:
195-
del self._component_buckets[component_ids]
184+
self._update_buckets(component_ids, proposal)
196185

197186
# If there has not been any proposal for the given components, don't calculate a
198187
# target power and just return `None`.
@@ -223,6 +212,26 @@ def calculate_target_power(
223212

224213
return target_power
225214

215+
def _update_buckets(
216+
self, component_ids: frozenset[ComponentId], proposal: Proposal | None
217+
) -> None:
218+
"""Update the component buckets with the given proposal."""
219+
if proposal is None:
220+
return
221+
222+
if proposal is not None:
223+
bucket = self._component_buckets.setdefault(component_ids, set())
224+
if proposal in bucket:
225+
bucket.remove(proposal)
226+
if (
227+
proposal.preferred_power is not None
228+
or proposal.bounds.lower is not None
229+
or proposal.bounds.upper is not None
230+
):
231+
bucket.add(proposal)
232+
elif not bucket:
233+
del self._component_buckets[component_ids]
234+
226235
@override
227236
def get_status(
228237
self,

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
from ..._internal._constants import MAX_BATTERY_DATA_AGE_SEC
2424
from ...microgrid import connection_manager
2525
from ...microgrid._data_sourcing.microgrid_api_source import (
26-
_BatteryDataMethods,
27-
_InverterDataMethods,
26+
_BATTERY_DATA_METHODS,
27+
_INVERTER_DATA_METHODS,
2828
)
2929
from ...microgrid._old_component_data import (
3030
BatteryData,
@@ -212,13 +212,13 @@ async def async_new( # noqa: DOC502 (ValueError is raised indirectly super.asyn
212212

213213
@override
214214
def _supported_metrics(self) -> set[Metric | TransitionalMetric]:
215-
return set(_BatteryDataMethods.keys())
215+
return set(_BATTERY_DATA_METHODS.keys())
216216

217217
@override
218218
def _extract_metric(
219219
self, data: BatteryData, metric: Metric | TransitionalMetric
220220
) -> float:
221-
return _BatteryDataMethods[metric](data)
221+
return _BATTERY_DATA_METHODS[metric](data)
222222

223223
@override
224224
def _subscribe(self) -> Receiver[BatteryData]:
@@ -270,13 +270,13 @@ async def async_new( # noqa: DOC502 (ValueError is raised indirectly by super.a
270270

271271
@override
272272
def _supported_metrics(self) -> set[Metric | TransitionalMetric]:
273-
return set(_InverterDataMethods.keys())
273+
return set(_INVERTER_DATA_METHODS.keys())
274274

275275
@override
276276
def _extract_metric(
277277
self, data: InverterData, metric: Metric | TransitionalMetric
278278
) -> float:
279-
return _InverterDataMethods[metric](data)
279+
return _INVERTER_DATA_METHODS[metric](data)
280280

281281
@override
282282
def _subscribe(self) -> Receiver[InverterData]:

tests/utils/graph_generator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def _battery_with_inverter(
133133
],
134134
)
135135

136+
# pylint: disable-next=too-many-branches
136137
def component(
137138
self,
138139
other: ComponentCategory | Component,

0 commit comments

Comments
 (0)