The fine docs say that elt in the various comprehension nodes are of type BaseAssignTargetExpression. This is a lie. Observe: in the syntactically correct and semantically plausible expression (i ** 2 for i in _), the elt is constructed from i**2 which is a BinaryOperation:
> echo "(i**2 for _ in _)" | python -m libcst.tool print -
Module(
body=[
SimpleStatementLine(
body=[
Expr(
value=GeneratorExp(
elt=BinaryOperation(
left=Name(
value='i',
),
operator=Power(),
right=Integer(
value='2',
),
),
for_in=CompFor(
target=Name(
value='i',
),
iter=Name(
value='_',
),
),
),
),
],
),
],
)
But alas, BinaryOperation is not a BaseAssignTargetExpression.
>>> issubclass(cst.BinaryOperation, cst.BaseAssignTargetExpression)
False
What is the correct type for elt here? BaseExpression?
The fine docs say that
eltin the various comprehension nodes are of typeBaseAssignTargetExpression. This is a lie. Observe: in the syntactically correct and semantically plausible expression(i ** 2 for i in _), theeltis constructed fromi**2which is aBinaryOperation:But alas,
BinaryOperationis not aBaseAssignTargetExpression.What is the correct type for
elthere?BaseExpression?