.py files. Python has a single grammar construct for functions. Async functions parse as the same function_definition node, with the async keyword folded into it. Both sync and async def become Function.
What it detects
- Functions:
def(sync and async) becomesFunction - Classes:
class_definitionbecomesClass; methods areFunctionnodes nested inside - Decorators:
decoratorbecomesDecorator; a decorated definition becomes aDecoratedDefwrapper around the underlying function or class - Imports:
import_statement,import_from_statement, andfuture_import_statementall becomeImport - Assignments:
assignmentandaugmented_assignmentbecomeAssignment/AugmentedAssignment. Assignment labels come from the left-hand expression; there is no separateVariableconcept - Control flow: if / elif / else, for / while, try / except / finally, with, match / case
- Comprehensions and lambdas: list / dict / set comprehensions, generator expressions,
lambda - Type annotations:
type,generic_type, andunion_typebecomeTypeAnnotation/GenericType/UnionType
Node type mapping
Node types without a mapping keep their raw tree-sitter type name.
Function and class labels come from the definition’s
name field. A
DecoratedDef wrapper keeps the underlying definition’s name. Assignments use
their left-hand expression as a label. Human reports retain class assignments,
while local assignment details are grouped under their function.
Example: decorated functions and class assignments
Change a class setting, rename a decorated function, and edit its return value:before.py
after.py
differens before.py after.py:
Example: move and edit a helper across files
Compare two directory snapshots. The destination module already exists, and the helper keeps its name while its body changes. This separates a modified move from the within-file rename example above:old/pricing.py
new/pricing.py
old/discounts.py
new/discounts.py
edited for a modified
declaration move, and JSON exposes modified: true. The move summary pairs the
supported declaration edits. Other edits, such as a
new import, remain in the report. Renaming the helper during the move can prevent
that pairing; use the original per-file JSON actions when investigating it.
Known limitations
- Methods are not distinct: there is no
Methodconcept; a method is aFunctionnested in aClass. - Assignments use
Assignment, notVariable; their labels contain the left-hand expression. - Decorators and bodies have separate tree nodes; human reports may group their edits under the named definition.
- Lambdas have no label:
lambdabecomesLambdawith no name. - Unmapped node types pass through: anything outside the map keeps its raw tree-sitter type name.