python

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0, MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package python is the Python source-language plugin: packages and imports, the facts `analyze` scores, the PyPI-to-Go table lookup, and the exported functions and classes of a unit with type hints mapped into the TS-like type dialect. It is the counterpart of rust-anything's `lang/python.rs` and the Python parts of `lang/effects.rs`.

It parses with tree-sitter (`internal/syntax`), as the reference does.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExports

func FileExports(path string, source []byte) ([]lang.Fn, []lang.Class)

FileExports reads the public module-level functions and classes of one file's text, before they are sorted into exports and kept. The tests and `profile` read through it.

func SkipDirs

func SkipDirs() []string

SkipDirs lists the folder names Python discovery skips.

func ToTSType

func ToTSType(hint string) string

ToTSType maps a Python type hint into the TS-like type dialect: `list[str]` -> `string[]`, `Optional[int]` -> `int | undefined`, `Callable[...]` -> a function type (which keeps the export in Python).

Types

type Observed

type Observed struct {
	Mutates []string
	Prints  bool
}

Observed is what a function does that the recording sees: the parameters it changes in place, and whether it writes to standard output. Judged from the text; a miss is caught by `diff`, which compares the arguments after the call whatever this says.

type Plugin

type Plugin struct{}

Plugin is Python as a source language. It implements core.Plugin and lang.Analyzer.

func (Plugin) Detect

func (Plugin) Detect(root string) int

Detect scores a repository: a Python manifest at the root beats everything (the reference detects by manifest first, Python before `package.json`), otherwise the number of `.py` files a standard walk finds.

func (Plugin) Discover

func (Plugin) Discover(root string) (*lang.Workspace, error)

Discover finds the packages and source files under root.

func (Plugin) Exports

func (Plugin) Exports(root, unit string) (*core.UnitExports, error)

Exports reads one unit (a unit id from `analyze`, or a source file, relative to root) and sorts what it offers into what can cross the bridge and what stays in the original.

func (Plugin) Extensions

func (Plugin) Extensions() []string

Extensions are the extensions of Python source files.

func (Plugin) Lang

func (Plugin) Lang() core.Lang

Lang is core.LangPython.

func (Plugin) Lookup

func (Plugin) Lookup(dep string) (modules.Match, bool)

Lookup is the Go counterpart of a PyPI package (or import name), when the table knows it.

func (Plugin) Name

func (Plugin) Name() string

Name is the language as plans print it.

func (Plugin) NeedsHost

func (Plugin) NeedsHost(platforms []lang.Platform) bool

NeedsHost is always false: Python has no portable/host split.

func (Plugin) Registry

func (Plugin) Registry() string

Registry is where third-party dependencies come from.

func (Plugin) Resolve

func (Plugin) Resolve(from, spec string, ix *lang.Index) lang.Resolution

Resolve says where an import of `from` points. A standard-library module is ToPlatform.

func (Plugin) Scan

func (Plugin) Scan(path, text string) *lang.FileFacts

Scan reads one file: path is relative to the root, text is already decoded.

func (Plugin) SkipsDir

func (Plugin) SkipsDir(root, dir string) bool

SkipsDir reports whether Python discovery skips the folder dir (relative to root, with `/`) because of its name: a dependency tree, a virtual environment, build output.

func (Plugin) UnitBridge

func (Plugin) UnitBridge(portable bool) core.BridgeKind

UnitBridge: every Python unit reaches Go through the C shared library.

Jump to

Keyboard shortcuts

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