Skip to main content

Module python

Module python 

Source
Expand description

Python language parser using Tree-sitter

Extracts symbols from Python source code:

  • Functions (def, async def)
  • Classes (regular, abstract)
  • Methods (regular, async, static, class methods, properties via @property)
  • Decorators (tracked in scope)
  • Lambda expressions assigned to variables
  • Local variables (inside functions)
  • Global variables (module-level non-uppercase variables)
  • Constants (module-level uppercase variables)
  • Imports/Exports

Structs§

PythonDependencyExtractor
Python dependency extractor
PythonPackage
Represents a Python package configuration with its location

Functions§

find_all_python_configs
Recursively find all Python configuration files (pyproject.toml, setup.py, setup.cfg) in the repository, respecting .gitignore
find_python_package_name
Find the Python package name from pyproject.toml, setup.py, or setup.cfg This is used to determine which imports are internal vs external
parse
Parse Python source code and extract symbols
parse_all_python_packages
Parse all Python packages in a monorepo and track their project roots
parse_python_packages_from
parse_all_python_packages for config files already found (in walk order).
python_import_candidates
The paths a Python import can name, most specific first: a/b.py, then a/b/__init__.py (a package). Absolute imports need a package of the workspace whose name is the first component; relative ones (..x) are taken from current_file_path. No candidate starts with /: a package at the index root has an empty project root.
reclassify_python_import
Reclassify a Python import using the project’s package name Similar to reclassify_go_import() and reclassify_java_import()