diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2018-10-11 08:33:41 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-10-11 08:33:41 +0200 |
commit | ca20c869d86fbbf2d7ca28eaba1ffaa7bec75bba (patch) | |
tree | c22646ca94d0f337f71a88f07e83e861d3521bc8 /astroid/inference.py | |
parent | cd33ae266250fb0c6d60de378bebdc8f817c772c (diff) | |
download | astroid-git-ca20c869d86fbbf2d7ca28eaba1ffaa7bec75bba.tar.gz |
Replace a nested for loop with a product() call
Diffstat (limited to 'astroid/inference.py')
-rw-r--r-- | astroid/inference.py | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/astroid/inference.py b/astroid/inference.py index f66b1b63..c2ffd958 100644 --- a/astroid/inference.py +++ b/astroid/inference.py @@ -752,25 +752,18 @@ def _infer_binop(self, context): context = context or contextmod.InferenceContext() lhs_context = contextmod.copy_context(context) rhs_context = contextmod.copy_context(context) - - for lhs in left.infer(context=lhs_context): - if lhs is util.Uninferable: + lhs_iter = left.infer(context=lhs_context) + rhs_iter = right.infer(context=rhs_context) + for lhs, rhs in itertools.product(lhs_iter, rhs_iter): + if any(value is util.Uninferable for value in (rhs, lhs)): # Don't know how to process this. yield util.Uninferable return - for rhs in right.infer(context=rhs_context): - if rhs is util.Uninferable: - # Don't know how to process this. - yield util.Uninferable - return - - try: - yield from _infer_binary_operation( - lhs, rhs, self, context, _get_binop_flow - ) - except exceptions._NonDeducibleTypeHierarchy: - yield util.Uninferable + try: + yield from _infer_binary_operation(lhs, rhs, self, context, _get_binop_flow) + except exceptions._NonDeducibleTypeHierarchy: + yield util.Uninferable @decorators.yes_if_nothing_inferred |