Пример #1
0
def _remove_do_not_care(oldtype: cst.BaseExpression) -> cst.BaseExpression:
    """
    Given a BaseExpression from a type, return a new BaseExpression that does not
    refer to a DoNotCareSentinel.
    """
    return ensure_type(oldtype.visit(RemoveDoNotCareFromGeneric()),
                       cst.BaseExpression)
Пример #2
0
def _remove_types(oldtype: cst.BaseExpression,
                  values: Sequence[str]) -> cst.BaseExpression:
    """
    Given a BaseExpression from a type, return a new BaseExpression that does not
    refer to any types listed in values.
    """
    return ensure_type(oldtype.visit(RemoveTypesFromGeneric(values)),
                       cst.BaseExpression)
Пример #3
0
def _convert_match_nodes_to_cst_nodes(
    matchtype: cst.BaseExpression, ) -> cst.BaseExpression:
    """
    Given a BaseExpression in a type, convert this to a new BaseExpression that refers
    to LibCST nodes instead of forward references to matcher nodes.
    """
    return ensure_type(matchtype.visit(MatcherClassToLibCSTClass()),
                       cst.BaseExpression)