Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/libcst/__init__.py: 88%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Copyright (c) Meta Platforms, Inc. and affiliates.
2#
3# This source code is licensed under the MIT license found in the
4# LICENSE file in the root directory of this source tree.
6from libcst._batched_visitor import BatchableCSTVisitor, visit_batched
7from libcst._exceptions import CSTLogicError, MetadataException, ParserSyntaxError
8from libcst._flatten_sentinel import FlattenSentinel
9from libcst._maybe_sentinel import MaybeSentinel
10from libcst._metadata_dependent import MetadataDependent
11from libcst._nodes.base import CSTNode, CSTValidationError
12from libcst._nodes.expression import (
13 Annotation,
14 Arg,
15 Asynchronous,
16 Attribute,
17 Await,
18 BaseAssignTargetExpression,
19 BaseComp,
20 BaseDelTargetExpression,
21 BaseDict,
22 BaseDictElement,
23 BaseElement,
24 BaseExpression,
25 BaseFormattedStringContent,
26 BaseList,
27 BaseNumber,
28 BaseSet,
29 BaseSimpleComp,
30 BaseSlice,
31 BaseString,
32 BaseTemplatedStringContent,
33 BinaryOperation,
34 BooleanOperation,
35 Call,
36 Comparison,
37 ComparisonTarget,
38 CompFor,
39 CompIf,
40 ConcatenatedString,
41 Dict,
42 DictComp,
43 DictElement,
44 Element,
45 Ellipsis,
46 Float,
47 FormattedString,
48 FormattedStringExpression,
49 FormattedStringText,
50 From,
51 GeneratorExp,
52 IfExp,
53 Imaginary,
54 Index,
55 Integer,
56 Lambda,
57 LeftCurlyBrace,
58 LeftParen,
59 LeftSquareBracket,
60 List,
61 ListComp,
62 Name,
63 NamedExpr,
64 Param,
65 Parameters,
66 ParamSlash,
67 ParamStar,
68 RightCurlyBrace,
69 RightParen,
70 RightSquareBracket,
71 Set,
72 SetComp,
73 SimpleString,
74 Slice,
75 StarredDictComp,
76 StarredDictElement,
77 StarredElement,
78 Subscript,
79 SubscriptElement,
80 TemplatedString,
81 TemplatedStringExpression,
82 TemplatedStringText,
83 Tuple,
84 UnaryOperation,
85 Yield,
86)
87from libcst._nodes.module import Module
88from libcst._nodes.op import (
89 Add,
90 AddAssign,
91 And,
92 AssignEqual,
93 BaseAugOp,
94 BaseBinaryOp,
95 BaseBooleanOp,
96 BaseCompOp,
97 BaseUnaryOp,
98 BitAnd,
99 BitAndAssign,
100 BitInvert,
101 BitOr,
102 BitOrAssign,
103 BitXor,
104 BitXorAssign,
105 Colon,
106 Comma,
107 Divide,
108 DivideAssign,
109 Dot,
110 Equal,
111 FloorDivide,
112 FloorDivideAssign,
113 GreaterThan,
114 GreaterThanEqual,
115 ImportStar,
116 In,
117 Is,
118 IsNot,
119 LeftShift,
120 LeftShiftAssign,
121 LessThan,
122 LessThanEqual,
123 MatrixMultiply,
124 MatrixMultiplyAssign,
125 Minus,
126 Modulo,
127 ModuloAssign,
128 Multiply,
129 MultiplyAssign,
130 Not,
131 NotEqual,
132 NotIn,
133 Or,
134 Plus,
135 Power,
136 PowerAssign,
137 RightShift,
138 RightShiftAssign,
139 Semicolon,
140 Subtract,
141 SubtractAssign,
142)
143from libcst._nodes.statement import (
144 AnnAssign,
145 AsName,
146 Assert,
147 Assign,
148 AssignTarget,
149 AugAssign,
150 BaseCompoundStatement,
151 BaseSmallStatement,
152 BaseStatement,
153 BaseSuite,
154 Break,
155 ClassDef,
156 Continue,
157 Decorator,
158 Del,
159 Else,
160 ExceptHandler,
161 ExceptStarHandler,
162 Expr,
163 Finally,
164 For,
165 FunctionDef,
166 Global,
167 If,
168 Import,
169 ImportAlias,
170 ImportFrom,
171 IndentedBlock,
172 LazyImport,
173 LazyImportFrom,
174 Match,
175 MatchAs,
176 MatchCase,
177 MatchClass,
178 MatchKeywordElement,
179 MatchList,
180 MatchMapping,
181 MatchMappingElement,
182 MatchOr,
183 MatchOrElement,
184 MatchPattern,
185 MatchSequence,
186 MatchSequenceElement,
187 MatchSingleton,
188 MatchStar,
189 MatchTuple,
190 MatchValue,
191 NameItem,
192 Nonlocal,
193 ParamSpec,
194 Pass,
195 Raise,
196 Return,
197 SimpleStatementLine,
198 SimpleStatementSuite,
199 Try,
200 TryStar,
201 TypeAlias,
202 TypeParam,
203 TypeParameters,
204 TypeVar,
205 TypeVarTuple,
206 While,
207 With,
208 WithItem,
209)
210from libcst._nodes.whitespace import (
211 BaseParenthesizableWhitespace,
212 Comment,
213 EmptyLine,
214 Newline,
215 ParenthesizedWhitespace,
216 SimpleWhitespace,
217 TrailingWhitespace,
218)
219from libcst._parser.entrypoints import parse_expression, parse_module, parse_statement
220from libcst._parser.types.config import (
221 KNOWN_PYTHON_VERSION_STRINGS,
222 PartialParserConfig,
223)
224from libcst._removal_sentinel import RemovalSentinel, RemoveFromParent
225from libcst._visitors import CSTNodeT, CSTTransformer, CSTVisitor, CSTVisitorT
227try:
228 from libcst._version import version as LIBCST_VERSION
229except ImportError:
230 LIBCST_VERSION = "unknown"
231from libcst.helpers import ( # from libcst import ensure_type is deprecated, will be removed in 0.4.0
232 ensure_type,
233)
234from libcst.metadata.base_provider import (
235 BaseMetadataProvider,
236 BatchableMetadataProvider,
237 VisitorMetadataProvider,
238)
239from libcst.metadata.wrapper import MetadataWrapper
241__all__ = [
242 "KNOWN_PYTHON_VERSION_STRINGS",
243 "LIBCST_VERSION",
244 "BatchableCSTVisitor",
245 "CSTNodeT",
246 "CSTTransformer",
247 "CSTValidationError",
248 "CSTVisitor",
249 "CSTVisitorT",
250 "FlattenSentinel",
251 "MaybeSentinel",
252 "CSTLogicError",
253 "MetadataException",
254 "ParserSyntaxError",
255 "PartialParserConfig",
256 "RemoveFromParent",
257 "RemovalSentinel",
258 "ensure_type", # from libcst import ensure_type is deprecated, will be removed in 0.4.0
259 "visit_batched",
260 "parse_module",
261 "parse_expression",
262 "parse_statement",
263 "CSTNode",
264 "Module",
265 "Annotation",
266 "Arg",
267 "Asynchronous",
268 "Attribute",
269 "Await",
270 "BaseAssignTargetExpression",
271 "BaseComp",
272 "BaseDelTargetExpression",
273 "BaseDict",
274 "BaseDictElement",
275 "BaseElement",
276 "BaseExpression",
277 "BaseFormattedStringContent",
278 "BaseTemplatedStringContent",
279 "BaseList",
280 "BaseNumber",
281 "BaseSet",
282 "BaseSimpleComp",
283 "BaseSlice",
284 "BaseString",
285 "BinaryOperation",
286 "BooleanOperation",
287 "Call",
288 "Comparison",
289 "ComparisonTarget",
290 "CompFor",
291 "CompIf",
292 "ConcatenatedString",
293 "Dict",
294 "DictComp",
295 "DictElement",
296 "Element",
297 "Ellipsis",
298 "Float",
299 "FormattedString",
300 "FormattedStringExpression",
301 "FormattedStringText",
302 "TemplatedString",
303 "TemplatedStringText",
304 "TemplatedStringExpression",
305 "From",
306 "GeneratorExp",
307 "IfExp",
308 "Imaginary",
309 "Index",
310 "Integer",
311 "Lambda",
312 "LeftCurlyBrace",
313 "LeftParen",
314 "LeftSquareBracket",
315 "List",
316 "ListComp",
317 "Name",
318 "NamedExpr",
319 "Param",
320 "Parameters",
321 "ParamSlash",
322 "ParamStar",
323 "RightCurlyBrace",
324 "RightParen",
325 "RightSquareBracket",
326 "Set",
327 "SetComp",
328 "SimpleString",
329 "Slice",
330 "StarredDictComp",
331 "StarredDictElement",
332 "StarredElement",
333 "Subscript",
334 "SubscriptElement",
335 "Tuple",
336 "UnaryOperation",
337 "Yield",
338 "Add",
339 "AddAssign",
340 "And",
341 "AssignEqual",
342 "BaseAugOp",
343 "BaseBinaryOp",
344 "BaseBooleanOp",
345 "BaseCompOp",
346 "BaseUnaryOp",
347 "BitAnd",
348 "BitAndAssign",
349 "BitInvert",
350 "BitOr",
351 "BitOrAssign",
352 "BitXor",
353 "BitXorAssign",
354 "Colon",
355 "Comma",
356 "Divide",
357 "DivideAssign",
358 "Dot",
359 "Equal",
360 "FloorDivide",
361 "FloorDivideAssign",
362 "GreaterThan",
363 "GreaterThanEqual",
364 "ImportStar",
365 "In",
366 "Is",
367 "IsNot",
368 "LeftShift",
369 "LeftShiftAssign",
370 "LessThan",
371 "LessThanEqual",
372 "MatrixMultiply",
373 "MatrixMultiplyAssign",
374 "Minus",
375 "Modulo",
376 "ModuloAssign",
377 "Multiply",
378 "MultiplyAssign",
379 "Not",
380 "NotEqual",
381 "NotIn",
382 "Or",
383 "Plus",
384 "Power",
385 "PowerAssign",
386 "RightShift",
387 "RightShiftAssign",
388 "Semicolon",
389 "Subtract",
390 "SubtractAssign",
391 "AnnAssign",
392 "AsName",
393 "Assert",
394 "Assign",
395 "AssignTarget",
396 "AugAssign",
397 "BaseCompoundStatement",
398 "BaseSmallStatement",
399 "BaseStatement",
400 "BaseSuite",
401 "Break",
402 "ClassDef",
403 "Continue",
404 "Decorator",
405 "Del",
406 "Else",
407 "ExceptHandler",
408 "ExceptStarHandler",
409 "Expr",
410 "Finally",
411 "For",
412 "FunctionDef",
413 "Global",
414 "If",
415 "Import",
416 "ImportAlias",
417 "ImportFrom",
418 "LazyImport",
419 "LazyImportFrom",
420 "IndentedBlock",
421 "Match",
422 "MatchCase",
423 "MatchAs",
424 "MatchClass",
425 "MatchKeywordElement",
426 "MatchList",
427 "MatchMapping",
428 "MatchMappingElement",
429 "MatchOr",
430 "MatchOrElement",
431 "MatchPattern",
432 "MatchSequence",
433 "MatchSequenceElement",
434 "MatchSingleton",
435 "MatchStar",
436 "MatchTuple",
437 "MatchValue",
438 "NameItem",
439 "Nonlocal",
440 "Pass",
441 "Raise",
442 "Return",
443 "SimpleStatementLine",
444 "SimpleStatementSuite",
445 "Try",
446 "TryStar",
447 "While",
448 "With",
449 "WithItem",
450 "BaseParenthesizableWhitespace",
451 "Comment",
452 "EmptyLine",
453 "Newline",
454 "ParenthesizedWhitespace",
455 "SimpleWhitespace",
456 "TrailingWhitespace",
457 "BaseMetadataProvider",
458 "BatchableMetadataProvider",
459 "VisitorMetadataProvider",
460 "MetadataDependent",
461 "MetadataWrapper",
462 "TypeVar",
463 "TypeVarTuple",
464 "ParamSpec",
465 "TypeParam",
466 "TypeParameters",
467 "TypeAlias",
468]