diff --git a/doc/release_notes.md b/doc/release_notes.md index a57130d3c1..56787b911e 100644 --- a/doc/release_notes.md +++ b/doc/release_notes.md @@ -49,6 +49,7 @@ - doc: Disable root TOC entries in order to declutter the table of contents for the rules overview ([2216](https://github.com/PyPSA/pypsa-eur/pull/2216)). +* fix: Ensure `inflow_t` is always defined in `attach_hydro`, resolving a pylint use-before-assignment issue ([#2224](https://github.com/PyPSA/pypsa-eur/pull/2224)). * Add missing regex anchor with `re.fullmatch` to `create_zenodo_deposition_cli` utils script ([#2225](https://github.com/PyPSA/pypsa-eur/pull/2225)). ## PyPSA-Eur v2026.02.0 (18th February 2026) diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 492c50e934..e7d824eb62 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -770,6 +770,7 @@ def attach_hydro( country = ppl["bus"].map(n.buses.country).rename("country") inflow_idx = ror.index.union(hydro.index) + inflow_t = pd.DataFrame() if not inflow_idx.empty: dist_key = ppl.loc[inflow_idx, "p_nom"].groupby(country).transform(normed) @@ -803,7 +804,7 @@ def attach_hydro( capital_cost=costs.at["ror", "capital_cost"], weight=ror["p_nom"], p_max_pu=( - inflow_t[ror.index] # pylint: disable=E0606 + inflow_t[ror.index] .divide(ror["p_nom"], axis=1) .where(lambda df: df <= 1.0, other=1.0) ),