Skip to content

[linopy v1 / linopy 0.8] Deprecated Constraint.lhs/.rhs setter used in constraint mutation #732

Description

@FBumann

Category: deprecated API (6 code sites) — linopy 0.8 deprecation, orthogonal to the semantics flag but blocks the build

Symptom

Under linopy 0.8, augmenting a constraint via the .lhs/.rhs setter emits:

DeprecationWarning: Constraint.lhs setter is deprecated and will be removed in
a future release; use Constraint.update(lhs=...) instead.

pyproject.toml escalates DeprecationWarning from the flixopt module to an error (error::DeprecationWarning:flixopt), so every model build aborts here before any semantics arithmetic even runs.

Location

  • flixopt/components.py TransmissionModelcon_transmission.lhs += ...
  • flixopt/features.py ShareAllocationModel_eq_total.lhs -= ... (×3), share_constraints[name].lhs -= ...
  • flixopt/elements.py BusModeleq_bus_balance.lhs += ...

Root cause

linopy 0.8 makes Constraint.update(...) the single mutation API and deprecates the .lhs/.rhs setters (the getters are fine).

Repro

Any effect/bus/transmission model build under linopy 0.8 with flixopt's strict pytest filterwarnings.

Proposed fix

con.lhs += exprcon.update(lhs=con.lhs + expr). Works on linopy 0.8; equivalent under both semantics.

Severity

Build-breaking under linopy 0.8 (via flixopt's warning-as-error config). Not a v1-semantics rule per se, but a prerequisite for running under the v1-capable linopy.

Fixed in #729.

Metadata

Metadata

Assignees

No one assigned

    Labels

    linopy-v1Compatibility with linopy v1 semantics (PR #717)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions