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

24 statements  

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. 

5 

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 StarredDictElement, 

76 StarredElement, 

77 Subscript, 

78 SubscriptElement, 

79 TemplatedString, 

80 TemplatedStringExpression, 

81 TemplatedStringText, 

82 Tuple, 

83 UnaryOperation, 

84 Yield, 

85) 

86from libcst._nodes.module import Module 

87from libcst._nodes.op import ( 

88 Add, 

89 AddAssign, 

90 And, 

91 AssignEqual, 

92 BaseAugOp, 

93 BaseBinaryOp, 

94 BaseBooleanOp, 

95 BaseCompOp, 

96 BaseUnaryOp, 

97 BitAnd, 

98 BitAndAssign, 

99 BitInvert, 

100 BitOr, 

101 BitOrAssign, 

102 BitXor, 

103 BitXorAssign, 

104 Colon, 

105 Comma, 

106 Divide, 

107 DivideAssign, 

108 Dot, 

109 Equal, 

110 FloorDivide, 

111 FloorDivideAssign, 

112 GreaterThan, 

113 GreaterThanEqual, 

114 ImportStar, 

115 In, 

116 Is, 

117 IsNot, 

118 LeftShift, 

119 LeftShiftAssign, 

120 LessThan, 

121 LessThanEqual, 

122 MatrixMultiply, 

123 MatrixMultiplyAssign, 

124 Minus, 

125 Modulo, 

126 ModuloAssign, 

127 Multiply, 

128 MultiplyAssign, 

129 Not, 

130 NotEqual, 

131 NotIn, 

132 Or, 

133 Plus, 

134 Power, 

135 PowerAssign, 

136 RightShift, 

137 RightShiftAssign, 

138 Semicolon, 

139 Subtract, 

140 SubtractAssign, 

141) 

142from libcst._nodes.statement import ( 

143 AnnAssign, 

144 AsName, 

145 Assert, 

146 Assign, 

147 AssignTarget, 

148 AugAssign, 

149 BaseCompoundStatement, 

150 BaseSmallStatement, 

151 BaseStatement, 

152 BaseSuite, 

153 Break, 

154 ClassDef, 

155 Continue, 

156 Decorator, 

157 Del, 

158 Else, 

159 ExceptHandler, 

160 ExceptStarHandler, 

161 Expr, 

162 Finally, 

163 For, 

164 FunctionDef, 

165 Global, 

166 If, 

167 Import, 

168 ImportAlias, 

169 ImportFrom, 

170 IndentedBlock, 

171 Match, 

172 MatchAs, 

173 MatchCase, 

174 MatchClass, 

175 MatchKeywordElement, 

176 MatchList, 

177 MatchMapping, 

178 MatchMappingElement, 

179 MatchOr, 

180 MatchOrElement, 

181 MatchPattern, 

182 MatchSequence, 

183 MatchSequenceElement, 

184 MatchSingleton, 

185 MatchStar, 

186 MatchTuple, 

187 MatchValue, 

188 NameItem, 

189 Nonlocal, 

190 ParamSpec, 

191 Pass, 

192 Raise, 

193 Return, 

194 SimpleStatementLine, 

195 SimpleStatementSuite, 

196 Try, 

197 TryStar, 

198 TypeAlias, 

199 TypeParam, 

200 TypeParameters, 

201 TypeVar, 

202 TypeVarTuple, 

203 While, 

204 With, 

205 WithItem, 

206) 

207from libcst._nodes.whitespace import ( 

208 BaseParenthesizableWhitespace, 

209 Comment, 

210 EmptyLine, 

211 Newline, 

212 ParenthesizedWhitespace, 

213 SimpleWhitespace, 

214 TrailingWhitespace, 

215) 

216from libcst._parser.entrypoints import parse_expression, parse_module, parse_statement 

217from libcst._parser.types.config import ( 

218 KNOWN_PYTHON_VERSION_STRINGS, 

219 PartialParserConfig, 

220) 

221from libcst._removal_sentinel import RemovalSentinel, RemoveFromParent 

222from libcst._visitors import CSTNodeT, CSTTransformer, CSTVisitor, CSTVisitorT 

223 

224try: 

225 from libcst._version import version as LIBCST_VERSION 

226except ImportError: 

227 LIBCST_VERSION = "unknown" 

228from libcst.helpers import ( # from libcst import ensure_type is deprecated, will be removed in 0.4.0 

229 ensure_type, 

230) 

231from libcst.metadata.base_provider import ( 

232 BaseMetadataProvider, 

233 BatchableMetadataProvider, 

234 VisitorMetadataProvider, 

235) 

236from libcst.metadata.wrapper import MetadataWrapper 

237 

238__all__ = [ 

239 "KNOWN_PYTHON_VERSION_STRINGS", 

240 "LIBCST_VERSION", 

241 "BatchableCSTVisitor", 

242 "CSTNodeT", 

243 "CSTTransformer", 

244 "CSTValidationError", 

245 "CSTVisitor", 

246 "CSTVisitorT", 

247 "FlattenSentinel", 

248 "MaybeSentinel", 

249 "CSTLogicError", 

250 "MetadataException", 

251 "ParserSyntaxError", 

252 "PartialParserConfig", 

253 "RemoveFromParent", 

254 "RemovalSentinel", 

255 "ensure_type", # from libcst import ensure_type is deprecated, will be removed in 0.4.0 

256 "visit_batched", 

257 "parse_module", 

258 "parse_expression", 

259 "parse_statement", 

260 "CSTNode", 

261 "Module", 

262 "Annotation", 

263 "Arg", 

264 "Asynchronous", 

265 "Attribute", 

266 "Await", 

267 "BaseAssignTargetExpression", 

268 "BaseComp", 

269 "BaseDelTargetExpression", 

270 "BaseDict", 

271 "BaseDictElement", 

272 "BaseElement", 

273 "BaseExpression", 

274 "BaseFormattedStringContent", 

275 "BaseTemplatedStringContent", 

276 "BaseList", 

277 "BaseNumber", 

278 "BaseSet", 

279 "BaseSimpleComp", 

280 "BaseSlice", 

281 "BaseString", 

282 "BinaryOperation", 

283 "BooleanOperation", 

284 "Call", 

285 "Comparison", 

286 "ComparisonTarget", 

287 "CompFor", 

288 "CompIf", 

289 "ConcatenatedString", 

290 "Dict", 

291 "DictComp", 

292 "DictElement", 

293 "Element", 

294 "Ellipsis", 

295 "Float", 

296 "FormattedString", 

297 "FormattedStringExpression", 

298 "FormattedStringText", 

299 "TemplatedString", 

300 "TemplatedStringText", 

301 "TemplatedStringExpression", 

302 "From", 

303 "GeneratorExp", 

304 "IfExp", 

305 "Imaginary", 

306 "Index", 

307 "Integer", 

308 "Lambda", 

309 "LeftCurlyBrace", 

310 "LeftParen", 

311 "LeftSquareBracket", 

312 "List", 

313 "ListComp", 

314 "Name", 

315 "NamedExpr", 

316 "Param", 

317 "Parameters", 

318 "ParamSlash", 

319 "ParamStar", 

320 "RightCurlyBrace", 

321 "RightParen", 

322 "RightSquareBracket", 

323 "Set", 

324 "SetComp", 

325 "SimpleString", 

326 "Slice", 

327 "StarredDictElement", 

328 "StarredElement", 

329 "Subscript", 

330 "SubscriptElement", 

331 "Tuple", 

332 "UnaryOperation", 

333 "Yield", 

334 "Add", 

335 "AddAssign", 

336 "And", 

337 "AssignEqual", 

338 "BaseAugOp", 

339 "BaseBinaryOp", 

340 "BaseBooleanOp", 

341 "BaseCompOp", 

342 "BaseUnaryOp", 

343 "BitAnd", 

344 "BitAndAssign", 

345 "BitInvert", 

346 "BitOr", 

347 "BitOrAssign", 

348 "BitXor", 

349 "BitXorAssign", 

350 "Colon", 

351 "Comma", 

352 "Divide", 

353 "DivideAssign", 

354 "Dot", 

355 "Equal", 

356 "FloorDivide", 

357 "FloorDivideAssign", 

358 "GreaterThan", 

359 "GreaterThanEqual", 

360 "ImportStar", 

361 "In", 

362 "Is", 

363 "IsNot", 

364 "LeftShift", 

365 "LeftShiftAssign", 

366 "LessThan", 

367 "LessThanEqual", 

368 "MatrixMultiply", 

369 "MatrixMultiplyAssign", 

370 "Minus", 

371 "Modulo", 

372 "ModuloAssign", 

373 "Multiply", 

374 "MultiplyAssign", 

375 "Not", 

376 "NotEqual", 

377 "NotIn", 

378 "Or", 

379 "Plus", 

380 "Power", 

381 "PowerAssign", 

382 "RightShift", 

383 "RightShiftAssign", 

384 "Semicolon", 

385 "Subtract", 

386 "SubtractAssign", 

387 "AnnAssign", 

388 "AsName", 

389 "Assert", 

390 "Assign", 

391 "AssignTarget", 

392 "AugAssign", 

393 "BaseCompoundStatement", 

394 "BaseSmallStatement", 

395 "BaseStatement", 

396 "BaseSuite", 

397 "Break", 

398 "ClassDef", 

399 "Continue", 

400 "Decorator", 

401 "Del", 

402 "Else", 

403 "ExceptHandler", 

404 "ExceptStarHandler", 

405 "Expr", 

406 "Finally", 

407 "For", 

408 "FunctionDef", 

409 "Global", 

410 "If", 

411 "Import", 

412 "ImportAlias", 

413 "ImportFrom", 

414 "IndentedBlock", 

415 "Match", 

416 "MatchCase", 

417 "MatchAs", 

418 "MatchClass", 

419 "MatchKeywordElement", 

420 "MatchList", 

421 "MatchMapping", 

422 "MatchMappingElement", 

423 "MatchOr", 

424 "MatchOrElement", 

425 "MatchPattern", 

426 "MatchSequence", 

427 "MatchSequenceElement", 

428 "MatchSingleton", 

429 "MatchStar", 

430 "MatchTuple", 

431 "MatchValue", 

432 "NameItem", 

433 "Nonlocal", 

434 "Pass", 

435 "Raise", 

436 "Return", 

437 "SimpleStatementLine", 

438 "SimpleStatementSuite", 

439 "Try", 

440 "TryStar", 

441 "While", 

442 "With", 

443 "WithItem", 

444 "BaseParenthesizableWhitespace", 

445 "Comment", 

446 "EmptyLine", 

447 "Newline", 

448 "ParenthesizedWhitespace", 

449 "SimpleWhitespace", 

450 "TrailingWhitespace", 

451 "BaseMetadataProvider", 

452 "BatchableMetadataProvider", 

453 "VisitorMetadataProvider", 

454 "MetadataDependent", 

455 "MetadataWrapper", 

456 "TypeVar", 

457 "TypeVarTuple", 

458 "ParamSpec", 

459 "TypeParam", 

460 "TypeParameters", 

461 "TypeAlias", 

462]