Codiga has joined Datadog!

Read the Blog
Skip to main content

JavaScriptNodeContext AST Python Object

The JavaScriptNodeContext is attached to each AST object for Python via the context attribute. It inherits the Context type.


  • currentFunction (array or FunctionDefinition): the current function we are in (null if we are not in a function)
  • currentClass (type ClassDefinition): the current class (or null if not in a class)
  • imports (array of type Import: list of all imports
  • assignments (array of type Assignment): list of assignments

Example of use

// Getting the context
const ctx = node.context;

// Getting the imports
const allImports = ctx.imports;