python

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const CallQueries = `
(call
  function: (identifier) @callee) @call

(call
  function: (attribute
    attribute: (identifier) @callee)) @call
`

CallQueries captures direct function and method call sites in Python. Matches:

  • plain calls: foo()
  • attribute/method calls: obj.method()
View Source
const ImportQueries = `` /* 285-byte string literal not displayed */

ImportQueries contains tree-sitter query patterns for Python import extraction. Matches import_statement and import_from_statement nodes:

  • plain import: import os → path="os", alias=""
  • aliased import: import os as op_sys → path="os", alias="op_sys"
  • from import: from os import path → path="os", alias=""
  • from relative import: from . import something → path=".", alias=""

Each match yields a @path capture (dotted_name or relative_import text) and an optional @alias capture (the identifier after 'as').

View Source
const Queries = `` /* 607-byte string literal not displayed */

Queries contains tree-sitter query patterns for Python symbol extraction. Covers:

  • top-level function definitions (def foo — direct children of module)
  • decorated top-level function definitions (@decorator def foo)
  • class definitions (class Foo)
  • decorated class definitions (@decorator class Foo)
  • method definitions (def foo inside a class body)
  • decorated method definitions (@decorator def foo inside a class body)

The @function patterns are anchored to module-level to avoid matching methods that are already captured by the @method patterns.

In Python's tree-sitter grammar, decorated definitions are wrapped in a decorated_definition node, so we need separate patterns for each case.

View Source
const RefQueries = `
(assignment
  right: (identifier) @ref)

(pair
  value: (identifier) @ref)

(keyword_argument
  value: (identifier) @ref)
`

RefQueries captures identifiers used as values (not called directly) in:

  • assignment statements: f = my_func (right-hand side plain identifier)
  • dict literal values: {"handler": my_func}
  • keyword arguments: handler=my_func

Combined with CallQueries in ExtractCalls so functions passed as values are recorded as "used" and do not appear as dead code.

Variables

View Source
var Extensions = []string{".py", ".pyw"}

Extensions lists file extensions handled by the Python grammar.

Language is the single shared tree-sitter language instance for Python.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL