Help us shape the future of Go! Take the 2026 Go Developer Survey

python

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

README

Python language package

Python-specific implementation lives here: the Flow block scanner, safe AST contract inspector, source parser, Python adapter examples, and Python runner profiles/templates under assets/. The language-neutral model lives in contract/; this package maps Python annotations into that model. Shared runner discovery, execution, installation, and asset loading live in the public core/ package. Host code should import github.com/nexssp/lang/core for the shared runtime.

The contract inspector recognizes top-level dataclasses and TypedDict classes with annotated fields. It uses Python's standard-library ast module and does not import or execute the inspected source. Python 3.8 or newer is required. Supported annotations map to neutral string, integer, number, boolean, array, object, or any types. Unknown custom classes are represented as objects; unions with multiple non-null types and heterogeneous fixed tuples become any (or arrays of any). It does not yet resolve inherited fields or third-party model metadata. This contract-inspection API is distinct from python.ExtractSignatures and the language-neutral github.com/nexssp/lang/extract parser, which emits source snippets and function counts for srcpack-style packaging.

From the module root:

go run ./cmd/nexss-lang inspect path/to/models.py
go run ./cmd/nexss-lang inspect --class Request path/to/models.py
go run ./cmd/nexss-lang generate --class Request --output request.nflow path/to/models.py

inspect prints JSON contracts, including source-level requiredness. generate writes @schema declarations and a commented pipeline example, so the generated file is a safe starter rather than an executable workflow. Flow's validate:"required" rule also rejects valid zero values, so the generator intentionally does not emit that tag; source-requiredness stays in the inspect JSON and is called out in the generated file. Python 3.8+ must be available as python3; pass --python to select another interpreter executable.

Documentation

Overview

Package python contains Python-specific source inspection, signature extraction, and NFlow assets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssetFiles

func AssetFiles() fs.FS

AssetFiles returns Python's embedded runner profiles and source templates, rooted at profiles/ and templates/.

func ExtractSignatures

func ExtractSignatures(src []byte, exportedOnly bool) (snippets []string, funcCount int, err error)

ExtractSignatures parses Python source and emits function and class signatures.

func Inspect

func Inspect(ctx context.Context, source, className string, options InspectOptions) ([]contract.Contract, error)

Inspect parses Python dataclasses and TypedDict declarations into the language-neutral contract model. If className is non-empty, only that class is returned; otherwise all supported top-level classes are inspected.

func IsTag

func IsTag(tag string) bool

IsTag reports whether tag resolves to the built-in Python language.

func NFlowFiles

func NFlowFiles() fs.FS

NFlowFiles exposes Python-specific examples rooted at "nflows/".

func ReadBlockBody

func ReadBlockBody(c *compiler.Parser) (string, error)

ReadBlockBody scans Python source directly, rather than relying on Flow's host lexer for comment and string boundaries. Braces in comments, ordinary strings, triple-quoted strings, and f-strings do not close the outer block.

Types

type InspectOptions

type InspectOptions struct {
	PythonCommand string
}

InspectOptions configures the Python interpreter used only to run the standard-library AST parser. Input modules themselves are never executed.

Directories

Path Synopsis
Package assets embeds Python runner profiles and source templates.
Package assets embeds Python runner profiles and source templates.

Jump to

Keyboard shortcuts

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