diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2018-10-10 12:28:22 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-10-10 12:28:22 +0200 |
commit | 03d5346872866489cc4e69152510ebffc6b012b8 (patch) | |
tree | 5011ff3c2ce6966f9895b7a9080944eb9f2b171d /astroid/inference.py | |
parent | 934f0ed0302b93044d67eb2e1ac9a3ae76d499a8 (diff) | |
download | astroid-git-03d5346872866489cc4e69152510ebffc6b012b8.tar.gz |
Replace a nested for loop with itertools.product
Diffstat (limited to 'astroid/inference.py')
-rw-r--r-- | astroid/inference.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/astroid/inference.py b/astroid/inference.py index 221fb062..e3c29dfb 100644 --- a/astroid/inference.py +++ b/astroid/inference.py @@ -791,25 +791,26 @@ def _infer_augassign(self, context=None): if context is None: context = contextmod.InferenceContext() - for lhs in self.target.infer_lhs(context=context): - if lhs is util.Uninferable: + rhs_context = context.clone() + + lhs_iter = self.target.infer_lhs(context=context) + rhs_iter = self.value.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 - rhs_context = context.clone() - for rhs in self.value.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_aug_flow - ) - except exceptions._NonDeducibleTypeHierarchy: - yield util.Uninferable + try: + yield from _infer_binary_operation( + left=lhs, + right=rhs, + binary_opnode=self, + context=context, + flow_factory=_get_aug_flow, + ) + except exceptions._NonDeducibleTypeHierarchy: + yield util.Uninferable @decorators.raise_if_nothing_inferred |