Skip to content

Commit e6e9469

Browse files
committed
Refactor a short code section of method _connect_subgroup of class Model of module modeltools slightly to avoid coveragepy wrongly reporting an uncovered continue line.
Due to CPython's peephole optimizer, see nedbat/coveragepy#198).
1 parent 63df4d5 commit e6e9469

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

hydpy/core/modeltools.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,9 +1149,9 @@ def element(self) -> None:
11491149
model.__hydpy_element__ = None
11501150

11511151
def connect(self) -> None:
1152-
"""Connect all |LinkSequence| objects and the selected |InputSequence|,
1153-
|ReceiverSequence|, and |OutputSequence| objects of the actual model to the
1154-
corresponding |NodeSequence| objects.
1152+
"""Connect all |LinkSequence| objects and the selected |InputSequence| and
1153+
|OutputSequence| objects of the actual model to the corresponding
1154+
|NodeSequence| objects.
11551155
11561156
You cannot connect any sequences until the |Model| object itself is connected
11571157
to an |Element| object referencing the required |Node| objects:
@@ -1541,13 +1541,13 @@ def _connect_subgroup(
15411541
selected_nodes.append(node)
15421542
if sequence.NDIM == 0:
15431543
if not selected_nodes:
1544-
if (group == "inputs") or not report_noconnect:
1545-
continue
1546-
raise RuntimeError(
1547-
f"Sequence {objecttools.elementphrase(sequence)} cannot "
1548-
f"be connected due to no available node handling variable "
1549-
f"`{sequence.name.upper()}`."
1550-
)
1544+
if report_noconnect and (group != "inputs"):
1545+
raise RuntimeError(
1546+
f"Sequence {objecttools.elementphrase(sequence)} "
1547+
f"cannot be connected due to no available node "
1548+
f"handling variable `{sequence.name.upper()}`."
1549+
)
1550+
continue
15511551
if len(selected_nodes) > 1:
15521552
raise RuntimeError(
15531553
f"Sequence `{sequence.name}` cannot be connected as it is "

0 commit comments

Comments
 (0)