LibCST/libcst/nodes/__init__.py
Benjamin Woodruff eae98942fd Implement Dict node
This implements the required nodes, but not the parsing logic (that'll
be a later diff).

To support `Dict`, this diff also introduces `BaseDictElement`,
`DictElement`, `StarredDictElement`, and `BaseDict`.

It also refactors some of the logic in `BaseSet` into `_BaseSetOrDict`
so that it can be shared between `BaseSet` and `BaseDict`.

`DictComp` will come later.
2019-07-26 12:48:22 -07:00

186 lines
3.4 KiB
Python

# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# pyre-strict
"""
This package contains CSTNode and all of the subclasses needed to express Python's full
grammar in a whitespace-sensitive fashion, forming a "Concrete" Syntax Tree (CST).
"""
# We don't export BaseLeaf/BaseValueToken from _base, because we consider those
# implementation details. Those base classes shouldn't be useful outside of this
# package.
from libcst.nodes._base import CSTNode, CSTValidationError # noqa: F401
from libcst.nodes._dummy import DummyNode # noqa: F401
from libcst.nodes._expression import ( # noqa: F401
Annotation,
Arg,
Asynchronous,
Attribute,
Await,
BaseAtom,
BaseComp,
BaseDict,
BaseDictElement,
BaseElement,
BaseExpression,
BaseFormattedStringContent,
BaseList,
BaseNumber,
BaseSet,
BaseString,
BinaryOperation,
BooleanOperation,
Call,
Comparison,
ComparisonTarget,
CompFor,
CompIf,
ConcatenatedString,
Dict,
DictElement,
Element,
Ellipses,
ExtSlice,
Float,
FormattedString,
FormattedStringExpression,
FormattedStringText,
From,
GeneratorExp,
IfExp,
Imaginary,
Index,
Integer,
Lambda,
LeftCurlyBrace,
LeftParen,
LeftSquareBracket,
List,
ListComp,
Name,
Param,
Parameters,
ParamStar,
RightCurlyBrace,
RightParen,
RightSquareBracket,
Set,
SetComp,
SimpleString,
Slice,
StarredDictElement,
StarredElement,
Subscript,
Tuple,
UnaryOperation,
Yield,
)
from libcst.nodes._internal import CodePosition, CodeRange # noqa: F401
from libcst.nodes._module import Module # noqa: F401
from libcst.nodes._op import ( # noqa: F401
Add,
AddAssign,
And,
AssignEqual,
BaseAugOp,
BaseBinaryOp,
BaseBooleanOp,
BaseCompOp,
BaseUnaryOp,
BitAnd,
BitAndAssign,
BitInvert,
BitOr,
BitOrAssign,
BitXor,
BitXorAssign,
Colon,
Comma,
Divide,
DivideAssign,
Dot,
Equal,
FloorDivide,
FloorDivideAssign,
GreaterThan,
GreaterThanEqual,
ImportStar,
In,
Is,
IsNot,
LeftShift,
LeftShiftAssign,
LessThan,
LessThanEqual,
MatrixMultiply,
MatrixMultiplyAssign,
Minus,
Modulo,
ModuloAssign,
Multiply,
MultiplyAssign,
Not,
NotEqual,
NotIn,
Or,
Plus,
Power,
PowerAssign,
RightShift,
RightShiftAssign,
Semicolon,
Subtract,
SubtractAssign,
)
from libcst.nodes._statement import ( # noqa: F401
AnnAssign,
AsName,
Assert,
Assign,
AssignTarget,
AugAssign,
BaseCompoundStatement,
BaseSmallStatement,
BaseSuite,
Break,
ClassDef,
Continue,
Decorator,
Del,
Else,
ExceptHandler,
Expr,
Finally,
For,
FunctionDef,
Global,
If,
Import,
ImportAlias,
ImportFrom,
IndentedBlock,
NameItem,
Nonlocal,
Pass,
Raise,
Return,
SimpleStatementLine,
SimpleStatementSuite,
Try,
While,
With,
WithItem,
)
from libcst.nodes._whitespace import ( # noqa: F401
Comment,
EmptyLine,
Newline,
ParenthesizedWhitespace,
SimpleWhitespace,
TrailingWhitespace,
)