Reference

Object conversion

To convert values between starlark and Python, JSON is currently being used as an intermediate format, which defines the scope of what is convertible. This, however, is subject to change.

References to Source Locations

class starlark.ResolvedFileSpan
file

A str.

span

A ResolvedSpan.

class starlark.ResolvedPos
line

A int.

column

A int.

class starlark.ResolvedSpan
begin

A ResolvedPos.

end

A ResolvedPos.

Diagnostics

exception starlark.StarlarkError
class starlark.EvalSeverity
Error
Warning
Advice
Disabled
class starlark.Lint
__str__()

Return str(self).

resolved_location

A ResolvedFileSpan.

short_name

A str.

severity

A EvalSeverity.

problem

A str.

original

A str.

Dialect

class starlark.DialectTypes
DISABLE
PARSE_ONLY
ENABLE
class starlark.Dialect
static standard() Dialect

static extended() Dialect

enable_def

A bool.

enable_lambda

A bool.

enable_load

A bool.

enable_keyword_only_arguments

A bool.

enable_types

A value of type DialectTypes.

enable_load_reexport

A bool.

enable_top_level_stmt

A bool.

enable_f_strings

A bool.

Note

These attributes are only writable (not readable) for the moment.

AST

class starlark.AstModule

See parse() to create objects of this type, and eval() to evaluate them.

lint() list[Lint]

Globals

class starlark.LibraryExtension
StructType
RecordType
EnumType
Map
Filter
Partial
ExperimentalRegex
Debug
Print
Pprint
Breakpoint
Json
Typing
Internal
CallStack
class starlark.Globals
static standard() Globals

static extended_by(extensions: list[LibraryExtension]) Globals

Modules

class starlark.Module

__getitem__(key, /)

Return self[key].

__setitem__(key, value, /)

Set self[key] to value.

add_callable(name: str, callable: Callable) None

freeze()
class starlark.FrozenModule

Loaders

class starlark.FileLoader(load_func: Callable[[str], FrozenModule])

Parsing and Evaluation

starlark.parse(filename, content, dialect=None)

Parse Starlark source code as a string and return an AST.

starlark.eval(module, ast, globals, file_loader=None)

Note that this consumes the ast argument, which is unusable after being passed to this fucntion.

Returns:

the value returned by the evaluation, after Object conversion.