Skip to content

Commit 46ca290

Browse files
authored
Merge pull request #2431 from ales-erjavec/canvas-link-priority-fix
[FIX] canvas: Fix proposed connection scoring for dynamic signals
2 parents 6a5f2f6 + aea473e commit 46ca290

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Orange/canvas/scheme/scheme.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from .link import SchemeLink, compatible_channels
2020
from .annotations import BaseSchemeAnnotation
2121

22-
from ..utils import check_arg, check_type
22+
from ..utils import check_arg, check_type, name_lookup
2323

2424
from .errors import (
2525
SchemeCycleError, IncompatibleChannelTypeError, SinkChannelError,
@@ -541,11 +541,19 @@ def propose_links(self, source_node, sink_node):
541541
if link.sink_channel.single]
542542

543543
def weight(out_c, in_c):
544+
# type: (OutputSignal, InputSignal) -> int
544545
if out_c.explicit or in_c.explicit:
545546
# Zero weight for explicit links
546547
weight = 0
547548
else:
548-
check = [not out_c.dynamic, # Dynamic signals are last
549+
# Does the connection type check (can only ever be False for
550+
# dynamic signals)
551+
type_checks = issubclass(name_lookup(out_c.type),
552+
name_lookup(in_c.type))
553+
assert type_checks or out_c.dynamic
554+
# Dynamic signals that require runtime instance type check
555+
# are considered last.
556+
check = [type_checks,
549557
in_c not in already_connected_sinks,
550558
bool(in_c.default),
551559
bool(out_c.default)

0 commit comments

Comments
 (0)