@decorators.raise_if_nothing_inferred<EOL>def with_assigned_stmts(self, node=None, context=None, assign_path=None):
try:<EOL><INDENT>mgr = next(mgr for (mgr, vars) in self.items if vars == node)<EOL><DEDENT>except StopIteration:<EOL><INDENT>return None<EOL><DEDENT>if assign_path is None:<EOL><INDENT>yield from _infer_context_manager(self, mgr, context)<EOL><DEDENT>else:<EOL><INDENT>for result in _infer_context_manager(self, mgr, context):<EOL><INDENT>obj = result<EOL>for index in assign_path:<EOL><INDENT>if not hasattr(obj, "<STR_LIT>"):<EOL><INDENT>raise exceptions.InferenceError(<EOL>"<STR_LIT>",<EOL>node=self,<EOL>targets=node,<EOL>assign_path=assign_path,<EOL>context=context,<EOL>)<EOL><DEDENT>try:<EOL><INDENT>obj = obj.elts[index]<EOL><DEDENT>except IndexError as exc:<EOL><INDENT>raise exceptions.InferenceError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>node=self,<EOL>targets=node,<EOL>assign_path=assign_path,<EOL>context=context,<EOL>) from exc<EOL><DEDENT>except TypeError as exc:<EOL><INDENT>raise exceptions.InferenceError(<EOL>"<STR_LIT>" "<STR_LIT>",<EOL>node=self,<EOL>targets=node,<EOL>assign_path=assign_path,<EOL>context=context,<EOL>) from exc<EOL><DEDENT><DEDENT>yield obj<EOL><DEDENT><DEDENT>return dict(node=self, unknown=node, assign_path=assign_path, context=context)<EOL>
Infer names and other nodes from a *with* statement.

    This enables only inference for name binding in a *with* statement.
    For instance, in the following code, inferring `func` will return
    the `ContextManager` class, not whatever ``__enter__`` returns.
    We are doing this intentionally, because we consider that the context
    manager result is whatever __enter__ returns and what it is binded
    using the ``as`` keyword.

        class ContextManager(object):
            def __enter__(self):
                return 42
        with ContextManager() as f:
            pass

        # ContextManager().infer() will return ContextManager
        # f.infer() will return 42.

    Arguments:
        self: nodes.With
        node: The target of the assignment, `as (a, b)` in `with foo as (a, b)`.
        context: Inference context used for caching already inferred objects
        assign_path:
            A list of indices, where each index specifies what item to fetch from
            the inference results.