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.ResolvedSpan#
begin_line#

A int.

begin_column = <method 'begin_column' of 'builtins.ResolvedSpan' objects>#

A int.

end_line = <method 'end_line' of 'builtins.ResolvedSpan' objects>#

A int.

end_column = <method 'end_column' of 'builtins.ResolvedSpan' objects>#

A int.

Diagnostics#

exception starlark.StarlarkError#
class starlark.Lint#
__str__()#

Return str(self).

resolved_location#

A ResolvedFileSpan.

short_name#

A str.

serious#

A bool.

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_keyword_only_arguments#

A bool.

enable_types#

A value of type DialectTypes.

enable_tabs#

A bool.

enable_load_reexport#

A bool.

enable_top_level_stmt#

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.Globals#
static standard() Globals#

static extended() 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.