package pyre-ast

  1. Overview
  2. Docs

This module provides a type that represents a Python with item.

Example: The statement with (f() as a, g()): ... contains 2 with items. The first one has f() as its context_expr and a as its optional_vars. The second one has g() as its context_expr and no optional_vars.

Note that optional_vars is "target"-like: It can only be one of a selected few kinds of expressions, and the corresponding expression context will always be set to ExpressionContext.store. See documentation of ExpressionContext for more details of which expressions are allowed.

type ('expr, 'with_item) t = context_expr:'expr -> optional_vars:'expr option -> 'with_item