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 = <method 'column' of 'builtins.ResolvedPos' objects>

A int.

class starlark.ResolvedSpan
begin

A ResolvedPos.

end = <method 'end' of 'builtins.ResolvedSpan' objects>

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(self) 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() Globals

Modules

class starlark.Module

__getitem__(key, /)

Return self[key].

__setitem__(key, value, /)

Set self[key] to value.

add_callable(self, name: str, callable: Callable) None

freeze(self) FrozenModule

class starlark.FrozenModule

Loaders

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

Parsing and Evaluation

starlark.parse(filename: str, content: str, dialect: Dialect | None = None) AstModule

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

starlark.eval(module: Module, ast: AstModule, globals: Globals, file_loader: FileLoader | None) object

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.