Skip to content

Commit 440bf86

Browse files
committed
Minor logic reordering to make the intent more clear
1 parent 7ab4028 commit 440bf86

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pyomo/repn/util.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,15 @@ def __init__(self, *args, **kwargs):
400400

401401
def __missing__(self, key):
402402
if type(key) is tuple:
403-
node_class = key[0]
404-
node_args = key[1:]
405403
# Only lookup/cache argument-specific handlers for unary,
406404
# binary and ternary operators
407-
if len(key) > 3:
408-
key = node_class
409-
if key in self:
410-
return self[key]
405+
if len(key) <= 3:
406+
node_class = key[0]
407+
node_args = key[1:]
408+
else:
409+
node_class = key = key[0]
410+
if node_class in self:
411+
return self[node_class]
411412
else:
412413
node_class = key
413414
bases = node_class.__mro__
@@ -446,7 +447,7 @@ def __missing__(self, key):
446447
def unexpected_expression_type(self, visitor, node, *args):
447448
raise DeveloperError(
448449
f"Unexpected expression node type '{type(node).__name__}' "
449-
f"found while walking expression tree in {type(self).__name__}."
450+
f"found while walking expression tree in {type(visitor).__name__}."
450451
)
451452

452453

0 commit comments

Comments
 (0)