MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / visit_Subscript

Method visit_Subscript

python/paddle/utils/gast/ast3.py:317–342  ·  view source on GitHub ↗
(self, node)

Source from the content-addressed store, hash-verified

315 if sys.version_info.minor < 9:
316
317 def visit_Subscript(self, node):
318 def adjust_slice(s):
319 if isinstance(s, ast.Slice):
320 return s
321 else:
322 return ast.Index(s)
323
324 if isinstance(node.slice, gast.Tuple):
325 if any(isinstance(elt, gast.slice) for elt in node.slice.elts):
326 new_slice = ast.ExtSlice(
327 [adjust_slice(x) for x in self._visit(node.slice.elts)]
328 )
329 else:
330 value = ast.Tuple(self._visit(node.slice.elts), ast.Load())
331 ast.copy_location(value, node.slice)
332 new_slice = ast.Index(value)
333 else:
334 new_slice = adjust_slice(self._visit(node.slice))
335 ast.copy_location(new_slice, node.slice)
336
337 new_node = ast.Subscript(
338 self._visit(node.value),
339 new_slice,
340 self._visit(node.ctx),
341 )
342 return ast.copy_location(new_node, node)
343
344 def visit_Assign(self, node):
345 new_node = ast.Assign(

Callers

nothing calls this directly

Calls 5

_visitMethod · 0.80
anyClass · 0.50
TupleMethod · 0.45
LoadMethod · 0.45
IndexMethod · 0.45

Tested by

no test coverage detected