Languages

Every target language is a class in literalizer.languages. You import the class, optionally configure it, and pass an instance to literalize().

Selecting a language

Each language class lives in literalizer.languages and is listed in ALL_LANGUAGES. Create an instance with its defaults, or override individual format options:

"""Select and configure a language."""

from literalizer import InputFormat, literalize
from literalizer.languages import Python

# Use all defaults
result = literalize(
    source='{"x": 1}',
    input_format=InputFormat.JSON,
    language=Python(),
)

# Override specific formats
result = literalize(
    source='{"x": 1}',
    input_format=InputFormat.JSON,
    language=Python(
        sequence_format=Python.sequence_formats.LIST,
        string_format=Python.string_formats.SINGLE,
        trailing_comma=Python.trailing_commas.NO,
    ),
)

Format options

Language classes define nested Enum classes that control how each data type is rendered. The available enums vary by language, but the most common ones are:

Enum

Controls

DateFormats

How datetime.date values are rendered (e.g. ISO string, constructor call).

DatetimeFormats

How datetime.datetime values are rendered.

BytesFormats

Bytes encoding (hex, base64, or language-native).

SequenceFormats

Collection type for lists (e.g. TUPLE, LIST, ARRAY, VEC, SLICE).

SetFormats

Collection type for sets (e.g. SET, FROZENSET, HASHSET).

DictFormats

Map type (e.g. DEFAULT, ORDERED, HASHMAP).

StringFormats

Quote style (SINGLE, DOUBLE, BACKTICK, RAW).

IntegerFormats

Numeric base (DECIMAL, HEX, OCTAL, BINARY).

FloatFormats

Float rendering (REPR, FIXED, SCIENTIFIC).

CommentFormats

Comment syntax (HASH, DOUBLE_SLASH, etc.).

DeclarationStyles

Variable declaration keyword (ASSIGN, LET, VAR, CONST).

TrailingCommas

Whether to emit a trailing comma in multi-line collections.

StatementTerminatorStyles

Statement terminator (SEMICOLON, NEWLINE, NONE).

Access a language’s enum members through the class itself, e.g. Go.sequence_formats.SLICE for Go slices or Go.date_formats.GO for the time.Date(...) constructor.

Each __init__ parameter has a sensible default, so you only need to specify the options you want to change.

Float emission scope

literalizer emits a syntactically valid source literal for any finite IEEE 754 double the target language accepts. Scientific-notation output always uses a dotted mantissa (1.0e+16 rather than 1e+16) so the result parses as a float in languages whose grammars reject a bare integer mantissa (Ada, Cobol, Elixir, Erlang, Gleam, Nix, YAML). Gleam additionally strips the + from positive exponents because its parser rejects the explicit sign; other languages keep the + because YAML’s resolver regex requires it to recognize the literal as a float.

Whether a round-trip through a target ecosystem’s JSON encoder preserves edge values such as DBL_MAX is governed by that ecosystem’s encoder (precision, integer-vs-float rendering, Inf coercion) and is out of scope for the formatter. Special floats (inf / nan) follow each language’s supports_special_floats policy; targets that have no expression for them (e.g. Gleam’s Erlang target) raise UnrepresentableSpecialFloatError.

Heterogeneous values

When the input data mixes value types that the target language’s natural collection type cannot hold, a heterogeneous_strategy constructor argument controls the outcome. Every language defaults to ERROR; some expose richer strategies such as TAGGED_ENUM or RECORD. See Heterogeneous strategies for the strategies, worked examples, and the per-language support matrix.

JSON value types

Some languages also have a single runtime JSON value type that is a better fit than native narrow collection types. These languages support this through the json_type constructor argument, accessed as <Language>.json_types.<VALUE>.

See also

Heterogeneous strategies for the statically typed alternative, and its “Which should I use?” note comparing the two approaches.

Rust is the worked example:

"""Render Rust data as serde_json::Value."""

from literalizer import InputFormat, NewVariable, literalize
from literalizer.languages import Rust

result = literalize(
    source='{"id": 1, "tags": ["red", 2]}',
    input_format=InputFormat.JSON,
    language=Rust(json_type=Rust.json_types.SERDE_JSON_VALUE),
    variable_form=NewVariable(name="payload"),
)

This emits serde_json::json!(...) expressions, relaxes Rust’s homogeneous Vec<T> / HashMap<K, V> checks, and requires dict keys to be strings so they remain valid JSON object keys.

Every mode requires dict keys to be strings for the same reason. The remaining languages differ only in the emitted form and a few extra constraints:

Language

json_type value

Emitted form

Notable constraints

Crystal

JSON_ANY

JSON.parse(%(...)) yielding JSON::Any

Rejects characters that break the %(...) literal (\, ", (, ), #{); rejects integers overflowing signed 64-bit.

Java

JACKSON_JSON_NODE

new ObjectMapper().readTree("...") yielding JsonNode

RECORD heterogeneous_strategy rejected.

Kotlin

KOTLINX_JSON_ELEMENT

Json.parseToJsonElement("...") yielding JsonElement

RECORD and TUPLE heterogeneous_strategy options rejected.

Scala

CIRCE

Json.obj(...) / Json.arr(...) with Json.fromXxx(...) scalars yielding io.circe.Json

None beyond string keys.

C#

SYSTEM_TEXT_JSON_NODE

new JsonObject { ... } / new JsonArray { ... } backed by System.Text.Json.Nodes

Dates / datetimes / times become ISO 8601 strings; the const modifier is rejected (the constructors are runtime expressions).

F#

SYSTEM_TEXT_JSON_NODE

JsonObject(dict [ ... ]) / JsonArray([| ... |]) with JsonValue.Create(...) scalars

Dates / datetimes / times become ISO 8601 strings unless datetime_format is EPOCH.

Nim

JSON_NODE

%*(...) backed by the standard-library json module

Dates / datetimes become ISO 8601 strings; CONST is rejected (%* is a runtime macro).

Haskell

AESON_VALUE

[aesonQQ| ... |] quasi-quote yielding Data.Aeson.Value

None beyond string keys.

Zig

STD_JSON_VALUE

std.json.parseFromSlice(std.json.Value, allocator, "...", .{}) catch unreachable with an injected std.heap.ArenaAllocator preamble

Dates / datetimes / times / bytes fold into strings; RECORD is rejected.

C++

NLOHMANN_JSON

nlohmann::json::parse(R"json(...)json") plus an #include <nlohmann/json.hpp> preamble line

Input must not encode the raw-string terminator )json".

Gleam

GLEAM_JSON_JSON

json.int / json.string / json.preprocessed_array / json.object builders yielding gleam/json.Json

Adds an import gleam/json line and drops the GVal ADT; non-finite floats rejected (the Erlang target cannot express them).

Elm

JSON_ENCODE_VALUE

Json.Encode.int / string / list identity / object calls yielding Json.Encode.Value

Adds an import Json.Encode line in place of the per-fixture Val ADT.

PureScript

ARGONAUT_JSON

fromRight jsonNull (jsonParser "...") yielding Data.Argonaut.Core.Json

Special floats (NaN, +Infinity, -Infinity) rejected.

Scheme

GUILE_JSON

Association lists (list (cons "k" v) ...), vectors (vector v ...), and the symbol 'null, ready for scm->json

Resolves the default mode’s object/array ambiguity; special floats (NaN, +inf.0, -inf.0) rejected.

Erlang

OTP_JSON

UTF-8 binary literals (<<"..."/utf8>>) for the built-in json module; null as the atom null; sets as JSON arrays

Requires the OTP_27 built-in json:encode/1.

Odin

JSON_VALUE

JSON text parsed at runtime by a package-scope _json_parse helper (over core:encoding/json.parse_string) yielding json.Value

Dates / datetimes / times / bytes fold into strings; RECORD is rejected.

C

CJSON

A cJSON_Create*(...) node tree composed with cJSON_AddItemToObject / cJSON_AddItemToArray plus an #include <cjson/cJSON.h> preamble, yielding cJSON *

Integers render through cJSON_CreateNumber((double)...) (cJSON has no integer node); RECORD is rejected.

Cobol

CJSON

The same cJSON_Create* tree built through GnuCOBOL’s C CALL interface across the WORKING-STORAGE and PROCEDURE divisions, yielding cJSON *

Integers are stored in a COMP-2 (C double) item; values beyond COBOL’s widest integer are rejected.

Two cases are unusual enough to keep as prose.

OCaml’s YOJSON_SAFE_T mode emits Yojson.Safe.t polymorphic-variant literals directly, keyed by the standard yojson tag set (Bool, Int, Float, String, Null, List, Assoc, Intlit), so the rendered binding has the static type Yojson.Safe.t instead of OCaml’s generated val_t algebraic type, and the type val_t = ... preamble drops out entirely:

let payload : Yojson.Safe.t = `Assoc [
    ("id", `Int 1);
    ("tags", `List [`String "red"; `Int 2])
]

Dates, datetimes, times, and bytes fold into JSON-friendly strings; integers that exceed OCaml’s native int range route through the Intlit arbitrary-precision escape hatch (a string-tagged JSON number) instead of raising.

D’s polarity is reversed from the others: its default already renders every value through std.json.JSONValue, so the json_type constructor argument selects the inverse mode. D.json_types.STD_JSON_VALUE is the default and matches the other languages’ opt-in JSON value rendering; passing json_type=None instead activates a narrow-typed mode that mirrors the typed-collection defaults the other languages provide:

"""Render D data through narrow native collections."""

from literalizer import InputFormat, NewVariable, literalize
from literalizer.languages import D

result = literalize(
    source='{"a": 1, "b": 2}',
    input_format=InputFormat.JSON,
    language=D(json_type=None),
    variable_form=NewVariable(name="counts"),
)

This emits raw D scalars, T[] array literals, and V[K] associative-array literals (auto counts = ["a": 1, "b": 2];) without the JSONValue wrapper. Inputs that have no narrow form, a heterogeneous list, a heterogeneous-valued dict, an empty list or dict (D’s auto cannot infer an element type for an empty literal), a set, an ordered map, or a non-record dict, are rejected with UnrepresentableInputError. The RECORD heterogeneous_strategy is also rejected because it already renders record-shaped dicts as generated struct literals, which conflicts with narrow mode’s associative-array form.

Empty mappings on Ada, Lua, PHP, and R

Ada, Lua, PHP, and R all have a runtime representation that cannot distinguish an empty mapping from an empty sequence. Lua’s table, PHP’s array, and R’s list() each serialize an empty mapping the same way their JSON encoders serialize an empty sequence (typically []). The Ada literalizer’s unified A_Val aggregate likewise collapses an empty AMap'[] and an empty AList'[] to the same runtime value, so the mapping/sequence distinction is lost on round-trip. literalize refuses to emit a literal that cannot round-trip and raises UnrepresentableEmptyDictError on those four languages whenever an empty mapping appears at any depth in the input. Empty sequences are unambiguous and are still accepted.

"""Ada, Lua, PHP, and R reject empty mappings."""

import contextlib
import json

from literalizer import InputFormat, NewVariable, literalize
from literalizer.exceptions import UnrepresentableEmptyDictError
from literalizer.languages import Lua

# Strip or replace the empty mapping before retrying on a real input.
with contextlib.suppress(UnrepresentableEmptyDictError):
    literalize(
        source=json.dumps(obj={"outer": {}}),
        input_format=InputFormat.JSON,
        language=Lua(),
        variable_form=NewVariable(name="my_data"),
    )

Forth visitor stream

Forth has no native mapping or sequence type, so the Forth language does not emit a data literal. Instead it emits a colon definition that executes a sequence of small constructor words, one per structural event in the document:

Word

Stack effect

Meaning

+obj

( -- )

start of an object

-obj

( -- )

end of an object

+arr

( -- )

start of an array

-arr

( -- )

end of an array

+key

( c-addr u -- )

a member name

+int

( n -- )

an integer value

+float

( F: r -- )

a floating-point value

+str

( c-addr u -- )

a string value

+bool

( flag -- )

a boolean value

+null

( -- )

a null value

For example, {"name": "Alice", "tags": [1, 2]} is literalized to:

: my_data
+obj
    s\" name" +key s\" Alice" +str
    s\" tags" +key +arr 1 +int 2 +int -arr
 -obj
;

The constructor words are the protocol; the caller supplies their bindings. The Forth language ships a default binding in src/literalizer/languages/forth_prelude.fs that writes JSON to a shared output stream through the Forth Foundation Library jos module, so loading the prelude and then running my_data prints the document as JSON out of the box:

include forth_prelude.fs
\ ... the literalized : my_data ... ; definition ...
my_data json-out str-get type

To consume the same definition another way – to build a Forth-side data structure, walk into custom storage, compute over the values, or emit a different format – redefine any of the constructor words before running the definition. Nothing in the definition is tied to JSON beyond the bindings the caller chooses to load.

Custom language implementations

To support a language that is not built in, create a class that satisfies the Language protocol, using metaclass=LanguageCls and defining the required nested enum classes and attributes.

When an attribute is part of the Language protocol but should resolve to None, expose that value through a descriptor or property instead of storing literal None on the class. CPython treats class-level None as “attribute is not implemented” during runtime protocol checks, which can prevent ABC cache warming for large @runtime_checkable protocols; see python/cpython#102433. Built-in languages use shared descriptors such as no_pygments_name and no_format_integer_widened for this pattern.

Look at any built-in language module under literalizer/languages/ for a complete working example. The Language protocol documents every required attribute.

Language-definition API

These symbols are only needed when defining a language that is not built in. Everything here is importable directly from the top-level literalizer package.

Formatting configuration

Building blocks used when defining how a language renders collections, comments and scalars.

class literalizer.CollectionLayout(*values)

Controls how nested collections are rendered.

COMPACT = 'compact'

Render nested collections on one line.

MULTILINE = 'multiline'

Render nested collections with one element per line.

class literalizer.TrailingCommaConfig(multiline_trailing_comma: bool)

Configuration for trailing-comma behavior.

When multiline_trailing_comma is True, trailing commas are added to multiline collections where the chosen format supports them. Some sequence formats (e.g. Java’s List.of()) do not support trailing commas; in those cases the trailing comma is omitted regardless of this setting.

multiline_trailing_comma: bool
class literalizer.CommentConfig(prefix: str, suffix: str)

Configuration for language comment syntax.

prefix: str
suffix: str
class literalizer.SequenceFormatConfig(sequence_open: Callable[[list[Value]], str], close: str, supports_heterogeneity: bool, single_element_trailing_comma: bool, supports_trailing_comma: bool, empty_sequence: str | None, preamble_lines: tuple[str, ...], format_entry: Callable[[Value, str], str], typed_opener_fallback: str | None, uses_typed_literal_for_scalars: bool, requires_uniform_record_shapes: bool, declared_type: str | None, narrowed_empty_form: Callable[[Sequence[list[Value]]], str] | None)

Configuration for a single sequence format.

close: str
declared_type: str | None
empty_sequence: str | None
format_entry: Callable[[Value, str], str]
narrowed_empty_form: Callable[[Sequence[list[Value]]], str] | None
preamble_lines: tuple[str, ...]
requires_uniform_record_shapes: bool
sequence_open: Callable[[list[Value]], str]
single_element_trailing_comma: bool
supports_heterogeneity: bool
supports_trailing_comma: bool
typed_opener_fallback: str | None
uses_typed_literal_for_scalars: bool
class literalizer.SetFormatConfig(set_open: Callable[[list[Value]], str], close: str, empty_set: str | None, preamble_lines: tuple[str, ...], set_opener_template: str, supports_heterogeneity: bool, supports_trailing_comma: bool)

Configuration for a single set format.

close: str
empty_set: str | None
preamble_lines: tuple[str, ...]
set_open: Callable[[list[Value]], str]
set_opener_template: str
supports_heterogeneity: bool
supports_trailing_comma: bool
with_typed_opener(*, type_to_opener: Callable[[type | ListType | DictType], str | None], fallback: str) SetFormatConfig

Return a copy with set_open replaced by a typed opener.

The type_to_opener callable is used to infer the opener from the element type. When inference fails, fallback is used instead.

class literalizer.DictFormatConfig(dict_open: Callable[[dict[Scalar, Value]], str], close: str, format_entry: Callable[[str, Value, str], str], empty_dict: str | None, preamble_lines: tuple[str, ...], narrowed_open: str | None, supports_trailing_comma: bool)

Configuration for dict formatting.

close: str
dict_open: Callable[[dict[Scalar, Value]], str]
empty_dict: str | None
format_entry: Callable[[str, Value, str], str]
narrowed_open: str | None
preamble_lines: tuple[str, ...]
supports_trailing_comma: bool
class literalizer.OrderedMapFormatConfig(ordered_map_open: Callable[[dict[Scalar, Value]], str], close: str, preamble_lines: tuple[str, ...])

Configuration for ordered-map formatting.

close: str
ordered_map_open: Callable[[dict[Scalar, Value]], str]
preamble_lines: tuple[str, ...]
class literalizer.DateFormatConfig(formatter: ~collections.abc.Callable[[~datetime.date], str], preamble_lines: tuple[str, ...] = (), type_produced: type = <class 'datetime.date'>)

Configuration for a single date format.

formatter: Callable[[date], str]
preamble_lines: tuple[str, ...] = ()
type_produced

alias of date

class literalizer.DatetimeFormatConfig(formatter: ~collections.abc.Callable[[~datetime.datetime], str], preamble_lines: tuple[str, ...] = (), type_produced: type = <class 'datetime.datetime'>)

Configuration for a single datetime format.

formatter: Callable[[datetime], str]
preamble_lines: tuple[str, ...] = ()
type_produced

alias of datetime

literalizer.fixed_open(*, open_str: str) Callable[[list[Value] | dict[Scalar, Value]], str]

Return an opener callable that always returns open_str.

Use this as sequence_open, set_open, dict_open, or ordered_map_open when the opening delimiter is a fixed string that does not depend on the collection contents.

Example: fixed_open(open_str="[")([1, 2, 3]) -> "[".

Defining a language

The Language protocol describes how a language formats literals. The members below are the contract each built-in language implements.

class literalizer.Language(*args, **kwargs)

Protocol describing how a language formats scalar literals and sequences.

Predefined instances for common languages are available as module-level constants in literalizer.languages (e.g. PYTHON, JAVASCRIPT). To support additional languages or override defaults, write a class that provides all the required attributes.

property allows_empty_call_parens: bool

Whether an empty argument list is written as ().

property bool_formats: type[Enum]

Enum class whose members list the boolean format options this language supports.

Languages without alternative boolean formats expose an empty enum so consumers can enumerate options uniformly without reflection.

property bytes_formats: type[Enum]

Enum class whose members list the bytes formats this language supports.

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Data-dependent preamble lines used for call rendering.

Most languages set this to the same callable as data_dependent_preamble. Languages whose declaration preamble does not apply to inline call arguments override it.

property call_returns_expression: bool

Whether a function call in this language is an expression whose value can be consumed by an enclosing expression. When False, literalize_call() rejects a call_transform (whose output wraps the call as a value) with UnsupportedCallShapeError.

property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle | CallSupport

Describes how this language passes arguments in function calls.

Returns a CallStyle variant for supported languages, or a CallSupport sentinel for languages with an empty CallStyles enum (distinguishing whether the language has no call syntax at all, or literalizer has not yet implemented call rendering for it).

property call_styles: type[Enum]

Enum class whose members list the call style options this language supports.

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

property comment_format: Enum

The comment format chosen for this language instance.

property comment_formats: type[Enum]

Enum class whose members list the comment formats this language supports.

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Computes body-preamble lines based on which types are present in the data. Most languages build this from scalar_body_preamble; Haskell overrides it to compose the data Val declaration and imports dynamically.

The second argument is the original data value, allowing implementations to inspect actual values when needed (e.g. to determine whether datetime microsecond-precision imports are required).

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type makes the language’s consume form illegal.

Returns True when the consume operator (e.g. Mojo ^) would be rejected for value, in which case the call site routes the ref through format_call_arg_ref_identifier instead of format_call_arg_ref_identifier_consumable.

Most languages set this to never_inhibits_consuming_form. Mojo overrides it: applying ^ to a register-trivial scalar (Int, Bool, Float64) is a hard error under --Werror, so those value types inhibit the consume form.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Callable that receives the original data value and returns extra preamble lines that depend on data content rather than just which scalar types are present.

Most languages use no_data_preamble() (returns ()); C++ uses this to conditionally emit its Any helper struct only when the data contains heterogeneous collections.

property date_format: Enum

The date format chosen for this language instance.

property date_formats: type[Enum]

Enum class whose members list the date formats this language supports.

property datetime_format: Enum

The datetime format chosen for this language instance.

property datetime_formats: type[Enum]

Enum class whose members list the datetime formats this language supports.

property declaration_style: Enum

The declaration style chosen for this language instance.

property declaration_styles: type[Enum]

Enum class whose members list the declaration style options this language supports.

property dict_entry_style: Enum

The dict entry style chosen for this language instance.

property dict_entry_styles: type[Enum]

Enum class whose members list the dict entry style options this language supports.

property dict_format: Enum

The dict/map format chosen for this language instance.

property dict_format_config: DictFormatConfig

Configuration for dict formatting.

property dict_formats: type[Enum]

Enum class whose members list the dict/map format options this language supports.

dict_supports_heterogeneous_values: bool

Whether the language’s dict format can represent values spanning multiple type families (e.g. Python’s dict, JavaScript’s object literal). When False (e.g. Rust’s HashMap), inputs with heterogeneous dict values raise MixedDictValuesError.

property element_separator: str

The separator placed between elements in inline sequences.

extension: str

The file extension for this language, including the leading dot.

property false_literal: str

The literal representing false/False.

property float_format: Enum

The float format chosen for this language instance.

property float_formats: type[Enum]

Enum class whose members list the float format options this language supports.

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: FormatCallArg

Rewrite a formatted direct call argument.

Called as format_call_arg(value, formatted) after value has been formatted as a literal or reference. Languages that do not need wrapping set this to identity_call_arg; languages such as C and Objective-C override this to wrap each argument in a canonical parameter type.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier used as a direct call argument (via literalize_call()).

In the call-argument context the referenced variable has already been emitted at the same top-level scope, so some languages that reject $ref in the value context (see format_call_ref_identifier) can accept it here.

The default implementation (provided by every language class) delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} call-argument identifier the caller authorized as consumable on literalize_call().

Used only for refs the caller listed in consumable_refs and that appear in exactly one call argument across the rendered calls, so the consuming form cannot strand a later use.

The default implementation (provided by every language class) delegates to format_call_arg_ref_identifier. Languages whose call-argument $ref semantics consume the variable (notably C++ std::move) override this.

format_call_binding_body_preamble() tuple[str, ...]

Module-internal body-preamble lines required only when a top-level binding holds an inference-bound call result.

Most languages need none and return () via no_call_binding_body_preamble. PureScript overrides this with import Prelude (its call stub returns Unit).

format_call_binding_file_pragmas() tuple[str, ...]

File-level compiler-pragma lines required only when a top-level binding holds an inference-bound call result.

Most languages need none and return () via no_call_binding_file_pragmas. Haskell overrides this to suppress -Wmissing-signatures for the binding, whose type the renderer cannot annotate.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Like format_call_stub but the lines are placed before the language wrapper — at file, package, or module scope.

Most languages return an empty tuple here and put all stubs in format_call_stub. Languages like Go that cannot declare types inside function bodies use this instead.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the form required by this language’s call expression syntax.

Used when a $ref appears as a value inside a data structure (e.g. an element of a list passed to literalize()). Languages that cannot support bare variable references in that context raise CallArgNotSupportedError here.

Called after literalize_call()’s ref_case normalization, so name is already in the requested identifier case. The second positional argument is the Value declared elsewhere for that ref (taken from the caller’s ref_values mapping), or None when the caller did not supply the value. Most languages emit ref identifiers bare and use identity_call_ref_identifier; languages that wrap the identifier in a type-sensitive way (V’s .clone() for non-scalars) inspect the value to choose the right form.

property format_call_statement: Callable[[str], str]

Rewrite an assembled call expression into a valid statement.

Languages that allow bare call statements set this to identity_call_statement; languages that need a wrapper such as let _ = ... override it.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declaration lines for a name used in a call expression.

parts is a sequence of name parts – a single element for simple function calls (e.g. ("process",)), multiple for method calls (e.g. ("throttler", "check")). The second argument is the list of parameter names (e.g. ["user_id", "ts"]) so that keyword-style languages can generate stubs with matching named parameters. stub_return controls the return type of the generated stub: StubReturn.VALUE when the call expression’s return value is consumed (e.g. passed as an argument to a transform wrapper), StubReturn.VOID otherwise. The fourth argument is the parsed call argument data: one entry per rendered call, where each entry is the arguments row for that call (a single value for one-parameter calls, a list of values for multi-parameter calls). Languages whose stubs need to be typed (e.g. Mojo) infer parameter types from this; other languages ignore it.

Stub lines are placed inside the language wrapper (e.g. inside func main() for Go, inside class Check for Java). Languages that need stubs at file/package scope should use format_call_preamble_stub instead.

Returns an empty tuple when no stub is needed (e.g. for built-in functions, or in languages whose lint checks only verify syntax).

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a sequence of call target parts into the form required by this language’s call expression syntax.

Most languages accept dotted member-access as-is and use identity_call_target. PHP overrides this to produce $app->client->fetch.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an ExistingVariable binding whose right-hand side is a call expression rather than a literal.

The call-expression counterpart of format_variable_assignment; see format_call_variable_declaration. Languages with no value-type tag reuse format_variable_assignment unchanged via default_format_call_variable_assignment.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a NewVariable declaration whose right-hand side is a call expression rather than a literal.

Languages whose literal-binding declaration injects a value-type-derived tag (Haskell’s x :: Val, F#’s x: Val = FInt ...) override this to drop the tag and let the compiler infer the call’s return type. Languages with no such tag reuse format_variable_declaration unchanged via default_format_call_variable_declaration.

property format_constructor_target: Callable[[str], str]

Return a zero-argument constructor target for class_name.

The returned string is intended to be passed to literalize_call() as target_function. Most languages call constructors as ClassName() and use identity_constructor_target; languages with constructor syntax outside regular function names override this to produce targets such as new ClassName, NewClassName, ClassName.new, or ClassName::new.

property format_date: Callable[[date], str]

Callable that formats a datetime.date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime.datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: Callable[[int], str] | None

Widened-integer formatter for mixed-magnitude int collections, or None when the language has no widening behavior.

Used only when a sequence/set mixes integers that do not all fit one fixed-width type (e.g. an i32 and a value past i32’s range); the formatter then casts every element to the wider type. Languages with no such widening (the common case) return None via no_format_integer_widened.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Callable that formats a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Callable that formats a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a datetime.time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

Called as format_variable_assignment(name, value, data) where name is the variable name, value is the already-formatted literal value, and data is the original parsed data structure.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

Called as format_variable_declaration(name, value, data, modifiers) where name is the variable name, value is the already-formatted literal value, data is the original parsed data structure, and modifiers is the set of modifier enum values requested by the caller. Each language exposes its modifier vocabulary as its nested Modifiers enum; values that are not members of that enum are silently ignored.

has_free_function_calls: bool

Whether the language has a free function call syntax (i.e. the ability to call a function by a bare name with no dot). Metadata for callers and the test harness, which use it to decide whether a generated bare-wrapper stub can compile in this language; literalize_call() does not inspect it.

property heterogeneous_behavior: HeterogeneousBehavior

Describes how this language handles heterogeneous scalar collections.

Languages that don’t wrap heterogeneous values expose NO_HETEROGENEOUS_BEHAVIOR. Languages that wrap them (e.g. Rust’s HeterogeneousStrategies.TAGGED_ENUM) return a HeterogeneousBehavior whose wrap_scalar and compute_wrap_ids implement the wrapping.

property heterogeneous_strategies: type[Enum]

Enum class whose members list the heterogeneous-scalar strategies this language supports.

Languages that only know how to raise on heterogeneous scalar collections expose a single-member enum whose only option is ERROR. Languages with richer strategies (e.g. Rust’s TAGGED_ENUM) expose additional members.

property heterogeneous_strategy: Enum

The heterogeneous-scalar strategy chosen for this language instance.

property identifier_cases: tuple[IdentifierCase, ...]

Identifier case conventions idiomatic for this language.

Ordered by stylistic preference – the first element is the language’s default/idiomatic case for generated defaults and golden fixtures. This list is not used to validate user ref_case choices; that role belongs to supported_ref_cases. A language may prefer only SNAKE while still syntactically supporting CAMEL, PASCAL, and UPPER_SNAKE.

property indent: str

The indentation step for elements inside delimiters in multi-line structures (e.g. "    " for 4-space indent).

property indent_closing_delimiter: bool

Whether to indent the closing delimiter of multi-line structures by one indent step.

property integer_format: Enum

The integer format chosen for this language instance.

property integer_formats: type[Enum]

Enum class whose members list the integer format options this language supports.

property integer_width_strategies: type[Enum]

Enum class whose members list the integer-width rendering strategies this language supports.

Most languages support only BareIntegerWidthStrategies.BARE (a bare numeric literal). Languages whose native scalar integer type silently loses precision past a fixed mantissa (notably Perl past 2**53) expose additional opt-in strategies that wrap wide values in an arbitrary-precision constructor.

property integer_width_strategy: Enum

The integer-width strategy chosen for this language instance.

property json_types: type[Enum]

Enum class whose members list the JSON value-type options this language supports.

Languages without a JSON value-type representation expose an empty enum so consumers can enumerate options uniformly without reflection.

property language_version: Enum

The selected version of the target language.

property leading_preamble: LeadingPreamble

Callable returning preamble lines that must come before static_preamble (and every other preamble line).

Receives the original data value and whether a new variable is being declared. Most languages use no_leading_preamble (always ()); Python uses it to emit from __future__ import annotations only when the rendered code actually contains an annotation, since that import must be the first statement.

property max_call_parameters: int

Maximum parameter count the language’s call syntax accepts.

NO_CALL_PARAMETER_LIMIT for languages with no fixed limit. When literalize_call() is given more parameter_names than this, it raises UnsupportedCallShapeError.

property modifiers: type[Enum]

Enum class whose members list the declaration modifiers this language supports.

Languages without modifier vocabulary expose an empty enum.

property null_literal: str

The literal representing null/None.

property numeric_literal_suffix: Enum

The numeric literal suffix chosen for this language instance.

property numeric_literal_suffixes: type[Enum]

Enum class whose members list the numeric literal suffix options this language supports.

property numeric_separator: Enum

The numeric separator option chosen for this language instance.

property numeric_separators: type[Enum]

Enum class whose members list the numeric separator options this language supports.

property numeric_style: Enum

The numeric literal style chosen for this language instance.

property numeric_styles: type[Enum]

Enum class whose members list the numeric literal style options this language supports.

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

property pygments_name: str | None

The Pygments lexer short name for syntax highlighting.

None if Pygments does not support this language.

property reserved_identifiers: frozenset[str]

Identifiers that are reserved by the language and therefore cannot appear as the innermost segment of target_function. literalize_call() rejects such targets with UnsupportedCallShapeError.

property scalar_body_preamble: dict[type, tuple[str, ...]]

Maps Python scalar types to body-preamble lines that are prepended to the generated code.

Most languages leave this empty. Haskell uses it for typeclass instance definitions.

property scalar_preamble: dict[type, tuple[str, ...]]

Maps Python scalar types to the preamble lines required when that type appears in the data. For example, a language that needs import datetime when dates are present would include {datetime.date: ("import datetime",)}.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Combine the per-binding bare_code snippets of a multi-binding file into one body.

Most languages join the snippets with newlines via default_sequence_binding_declarations. Languages that need ordering (Fortran: every specification statement before every executable one) or structural nesting (Nix’s chained let) override this.

property sequence_format: Enum

The sequence format chosen for this language instance.

sequence_format_config exposes the format-specific configuration (e.g. supports_heterogeneity).

property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

property sequence_formats: type[Enum]

Enum class whose members list the sequence formats this language supports.

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

Receives the list of items about to be formatted, so the delimiter can depend on the element types when needed. For a fixed delimiter use fixed_open().

property set_format: Enum

The set format chosen for this language instance.

property set_format_config: SetFormatConfig

Configuration for the chosen set format.

property set_formats: type[Enum]

Enum class whose members list the set formats this language supports.

property skip_null_dict_values: bool

Whether to omit dict entries whose value is None.

property special_float_preamble: tuple[str, ...]

Preamble lines added only when special float values (inf, -inf, nan) appear in the data. Most languages set this to (). Languages whose special-float literals require imports (e.g. Go needs import "math") populate this field so the import is only emitted when actually needed.

property statement_terminator: str

String appended to each call expression to form a complete statement.

Most C-family languages use ";". Python, Ruby, and other languages where a bare expression is a valid statement use "".

property statement_terminator_style: Enum

The statement terminator option chosen for this language instance.

property statement_terminator_styles: type[Enum]

Enum class whose members list the statement terminator options this language supports.

property static_body_preamble: Sequence[str]

Lines that are always prepended to the generated code, regardless of what types appear in the data. Appears after the header preamble but before the code body. Use an empty sequence when none are needed.

property static_preamble: Sequence[str]

Lines (imports, package declarations, etc.) that are always emitted before the generated code, regardless of what types appear in the data. Use an empty sequence when none are needed.

property string_format: Enum

The string format chosen for this language instance.

property string_formats: type[Enum]

Enum class whose members list the string format options this language supports.

property supported_ref_cases: frozenset[IdentifierCase]

Identifier cases that produce a syntactically legal identifier in this language.

Used solely for correctness validation: passing a IdentifierCase not in this set to literalize() or literalize_call() via ref_case is rejected with UnsupportedIdentifierCaseError. Independent of identifier_cases, which records stylistic preference rather than syntactic validity.

property supports_collection_comments: bool

Whether the language supports comments inside collection initializers.

When False, YAML comments on collection elements are emitted as standalone comment lines immediately before the collection (or before the variable declaration when a variable name is supplied) rather than being placed inside the {...} block.

supports_dict_literal_as_free_expression: bool

Whether a dict/map literal can appear as a free-standing expression (e.g. spliced as a call argument) rather than only on the right-hand side of a typed assignment. Metadata for the test harness only; literalize_call() does not inspect it. False for languages whose map-literal syntax needs a typed left-hand side to be sized – e.g. SystemVerilog '{...} assignment patterns.

supports_dotted_call_stub: bool

Whether the language can declare a stub for a dotted call wrapper name (e.g. tracer.emit). literalize_call() no longer inspects this (a context-aware call_transform is opaque); it is metadata for callers and the test harness, which use it to decide whether a generated dotted-wrapper stub can compile in this language.

supports_dotted_calls: bool

Whether the language accepts dotted target_function values (e.g. "module.fn") in literalize_call(). When False, dotted targets are rejected with DottedCallTargetNotSupportedError.

property supports_inline_multiline_dict_args: bool

Whether the language can render a call argument as an inline dict literal that spans multiple lines. When False, literalize_call() rejects inputs that would produce a multi-key dict argument with UnsupportedCallShapeError.

supports_multi_param_call_wrapper_stub: bool

Whether the language can declare, and positionally invoke, a harness wrapper stub that receives the call’s result alongside one or more additional positional arguments. Metadata for the test harness only; literalize_call() does not inspect it. False for languages whose generated multi-parameter stub cannot accept the call expression positionally – e.g. a strongly typed stub fed a void-returning call, or an object-style stub that rejects a positional multi-argument invocation.

supports_no_variable_wrap_in_file: bool

Whether the language can represent a bare value (no variable binding) at file-statement scope. When False, literalize() rejects wrap_in_file=True with variable_form=None with WrapInFileWithoutVariableNotSupportedEr ror, rather than silently emitting a file whose top-level item is a bare expression (a syntax error in strict-typed languages like Rust, C, Haskell, Swift, Ada, D, Dart, C#, Elm, Mojo, Nim, Objective-C, Odin, SML, V, Zig, etc.).

Languages with no variable-name syntax at all (supports_variable_names is False) must set this to True: their wrap_in_file output has no other shape.

supports_non_string_dict_keys: bool

Whether the language can represent a dict whose keys include values that are not strings. When False, literalize() rejects such inputs at the formatting boundary with UnrepresentableInputError.

Most languages allow scalar dict keys natively; pure data formats whose surface syntax only admits string keys (JSON-family, TOML) set this to False.

property supports_scalar_before_comments: bool

Whether the language supports a line comment between the assignment operator and the value on the next line.

For example, in JavaScript const x = // note\n42; is valid because the parser continues the incomplete expression past the line comment. In Python x = # note\n42 is a syntax error because the # comment terminates the statement.

When False, YAML comments that appear before a scalar value are emitted as standalone comment lines immediately before the variable declaration rather than between the = and the value.

property supports_scalar_inline_comments: bool

Whether the language supports a trailing line comment on a scalar value without breaking surrounding syntax.

For example, in JavaScript const x = 42  // note is valid because no closing token follows on the same line. In C ((_CVal){.i = 42  // note}); is a syntax error because the // comment consumes the closing });.

When False, YAML inline comments on scalar values are emitted as standalone comment lines immediately before the variable declaration rather than being appended after the value.

property supports_standalone_comments_in_wrapped_calls: bool

Whether manually wrapped call output can contain standalone comment lines between call statements.

supports_variable_names: bool

Whether the language supports wrapping output in a named variable via the variable_form argument to literalize(). When False, passing any NewVariable, ExistingVariable, or BothVariableForms is rejected with VariableNameNotSupportedError.

property supports_zero_parameter_calls: bool

Whether the language can render a function call with no parameters. When False, literalize_call() rejects empty parameter_names with UnsupportedCallShapeError.

property trailing_comma: Enum

The trailing comma option chosen for this language instance.

property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

Trailing commas are only added to collection formats that support them. See TrailingCommaConfig for details.

property trailing_commas: type[Enum]

Enum class whose members list the trailing comma options this language supports.

property true_literal: str

The literal representing true/True.

property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Callable that receives the set of collection types that have empty instances in the data and returns preamble lines needed for type-hint annotations.

Most languages return () unconditionally; Python uses this to emit from typing import Any only when the specific empty collection types present actually require it.

property validate_call_arg: Callable[[Value], None]

Validate a direct call argument after references are removed.

Languages that accept every supported literal set this to no_validate_call_arg; languages with additional call argument restrictions override it.

validate_spec_for_data(data: Value) None

Raise if the spec cannot produce valid code for data.

Languages whose output depends on format/data combinations that cannot produce valid code (e.g. Rust CONST + a dict value) override this method to raise IncompatibleFormatsError at literalize time. Languages with no such constraints assign no_validate_spec_for_data() as a no-op.

property variable_type_hints: Enum

The variable type hint option chosen for this language instance.

property variable_type_hints_formats: type[Enum]

Enum class whose members list the variable type hint options this language supports.

Every language exposes NEVER (no annotations, let the language infer), ALWAYS (annotate every variable), and SAFE. SAFE annotates only when the language’s own inference would widen the variable to a permissive type (e.g. unknown[] for an empty TypeScript array, Object[] for an empty Java array); for languages without a custom predicate it produces the same output as NEVER.

property version_formats: type[Enum]

Enum class whose members list the target language versions this language class supports.

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Wrap a sequence of top-level declarations (each one a full literalize bare_code for a $ref target) alongside a block of bare call expressions in a complete, valid file.

Most languages can splice the declarations directly in front of the calls and route through wrap_in_file() in call mode; they assign default_wrap_calls_with_declarations as a no-op wrapper. Languages whose call-mode wrapping moves bare expressions into a different scope than top-level bindings (e.g. Haskell’s main = do block, where bindings belong at module scope) override this method.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a declaration and assignment in a complete, valid file.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a code snippet in a complete, valid file.

class literalizer.LanguageCls

Meta-class that declares the nested format Enum class attributes.

Language classes use metaclass=LanguageCls so that downstream code can write dict[str, LanguageCls] and access cls.DateFormats, cls.SequenceFormats, etc. without cast or type: ignore.

Built-in languages

Built-in language specifications for common programming languages.

class literalizer.languages.Ada(*args: object, **kwargs: object)

Ada language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Ada call style options.

KEYWORD = KeywordCallStyle(separator=' => ')
class CommentFormats(*values)

Comment style options.

DOUBLE_DASH = CommentConfig(prefix='--', suffix='')
class DateFormats(*values)

Date format options for Ada.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Ada.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

DECLARE = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Ada.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence="AList'[]", preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Ada.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set="ASet'[]", preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Ada.

ADA_2022 = 1
allows_empty_call_parens = False
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = KeywordCallStyle(separator=' => ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='--', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Emit local IEEE-special constants when needed.

Ada has no portable inline literal for +Inf, -Inf or NaN: GNAT statically rejects 1.0 / 0.0 with static expression fails Constraint_Check. When the data contains one of these IEEE specials, declare matching local constants in the enclosing procedure’s declarative part using a volatile zero denominator so GNAT cannot constant-fold the division, and suppress Division_Check so the IEEE result propagates instead of raising Constraint_Error at runtime.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.adb'
false_literal: ClassVar[str] = 'ABool (False)'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Wrap a call argument in the appropriate A_Val constructor.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment binding a call result.

The call-expression counterpart of format_call_variable_declaration; the A_Val constructor wrapping is dropped since the call already yields an A_Val.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call result.

Unlike format_variable_declaration, the call result is opaque (it is whatever the A_Val-returning call stub returns), so the call result is bound directly with a plain A_Val declaration and no A_Val constructor wrapping.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

Ada distinguishes String from Character, so a literal consisting solely of Character'Val(N) would not satisfy the AStr (S : String) constructor. Prepend an empty string in that case so the & operator widens the result to String.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

module_name: str = 'Check'
module_name_case: ClassVar[IdentifierCase] = 'pascal'
null_literal: ClassVar[str] = 'ANull'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'ada'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Ada needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Ada needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence="AList'[]", preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set="ASet'[]", preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = False
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'ABool (True)'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

static validate_spec_for_data(data: Value) None

Reject inputs containing an empty mapping on Ada.

The Ada runtime stub renders empty container aggregates (AList'[], AMap'[]) by sharing a single Aggregate aspect on the unified A_Val private type, so an empty mapping and an empty sequence collapse to the same value at run time and the mapping/sequence distinction is lost on round-trip. Reject the empty mapping at literalize time rather than emit a literal that silently degrades.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Wrap Ada call stubs and variable declarations alongside calls.

Stubs and variable declarations go in the declarative section; call expressions go in the executable section.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap Ada declaration + assignment in a single procedure.

Earlier revisions wrapped each form in its own nested Check_Declaration / Check_Assignment procedure, but the assignment then referenced my_data from a sibling scope and only compiled because the lint job did syntax-only checking. Putting both in one procedure keeps the variable in scope so the fixture compiles and runs end-to-end.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap an Ada object declaration or call block inside a procedure.

When variable_name is non-empty (variable declaration mode), body_preamble and content go in the declarative section and the executable section contains only null;. When variable_name is empty (call mode), body_preamble (stubs) goes in the declarative section and content (calls) goes in the executable section.

class literalizer.languages.Bash(*args: object, **kwargs: object)

Bash language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Bash call style options.

COMMAND = CommandCallStyle(arg_separator=' ')
class CommentFormats(*values)

Comment style options.

HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for Bash.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Bash.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

DECLARE = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Bash.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Bash.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = <function _build_backslash_formatter.<locals>._format>
SINGLE = <function format_string_bash_single>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Bash.

V5_1 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = CommandCallStyle(arg_separator=' ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ' '
empty_dict_keys

alias of EmptyDictKey

extension = '.sh'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment binding a call expression.

The existing-variable counterpart of format_call_variable_declaration: a bare name="$(...)" with no declare keyword, matching the literal-binding assignment template.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call expression.

The literal-binding template assigns the right-hand side as a value word; a call result must be command-substituted with "$(...)" so the shell runs the command and captures its output instead of assigning the command name verbatim.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = '""'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'bash'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Bash needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Bash needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

static validate_call_arg(value: Value) None

Reject list, dict, and set values as Bash call arguments.

Bash commands take space-separated positional arguments and have no syntax for inline compound literals — cmd (1 2 3) parses as cmd followed by a nested (...) child-process group, and cmd (["k"]=v) likewise. Callers that need to pass a collection must declare it as a variable first and pass the name via a $ref marker.

validate_spec_for_data(data: Value) None

Raise for dict keys that Bash cannot represent.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.C(*args: object, **kwargs: object)

C language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

C call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for C.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for C.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

TYPED = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options.

C represents heterogeneous scalar collections with its tagged CVal union by default (ERROR). RECORD instead renders each record-shaped dict (non-empty, string-keyed) as a generated aggregate struct declared in the preamble plus a matching (struct Record0){.field = value, ...} designated-initializer compound literal, so a field may be a cleanly-typed scalar or a nested struct rather than a CVal union slot.

ERROR = 1
RECORD = 2
class IntegerFormats(*values)

Integer format options.

DECIMAL = <class 'str'>
HEX = <function format_integer_hex>
class JsonTypes(*values)

JSON value type options for C.

CJSON = 'cJSON'

The cJSON library’s cJSON * dynamic JSON value type from <cjson/cJSON.h>.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

AUTO = 2
NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for C.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}})', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for C.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}})', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for C.

C99 = 1
allows_empty_call_parens = True
array_field: str = 'a'
bool_field: str = 'b'
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

Under RECORD these are the generated struct RecordN declarations, emitted after the static CVal / CKV type declarations (a record field may itself be const CVal *).

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.c'
property false_literal: str

Literal representing False.

Bare false under RECORD (a clean bool record field); _format_entry re-wraps it for CVal contexts.

float_field: str = 'f'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Wrap each call argument in the CVal union so call sites match the concrete prototype emitted by _c_call_stub().

Under json_type=CJSON a scalar argument is rendered inline as a single cJSON_Create*(...) expression instead (the rendered CVal text is discarded), matching the cJSON * stub prototype.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

Under json_type=CJSON the universal value type is cJSON * (zero value NULL) rather than the tagged CVal union, so the stub prototypes and bodies use it.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment binding a call result.

The call-expression counterpart of format_variable_assignment; the compound-literal wrapping is dropped since the call already yields a CVal.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call result.

A literal binding wraps the right-hand side in a designated- initializer compound literal that encodes the value’s runtime type; a call’s return type is opaque to the renderer and is always the universal CVal union (the type every generated call stub returns), so the call result is bound directly with a plain CVal declaration and no compound-literal wrapping.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Callable that formats one sequence entry.

property format_set_entry: Callable[[Value, str], str]

Callable that formats one set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

The combined declaration+assignment form is only exercised for a top-level record-shaped dict, so a RECORD reassignment is a plain my_data = (struct Record0){...}; struct copy.

Under json_type=CJSON the value is rebuilt as a fresh cJSON node tree and the existing binding is reassigned to its root. A distinct _m node prefix (the declaration build uses _n) keeps the combined declaration+assignment form free of duplicate cJSON * definitions in one scope.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

Under RECORD a record-shaped root is declared with its generated struct type (struct Record0 my_data = (struct Record0){...};) and an all-record-list root as an array (struct Record0 my_data[] = {...};); every other value keeps the CVal-wrapped form.

Under json_type=CJSON the rendered CVal value is discarded: the data is built as a cJSON_Create*(...) node tree (one statement per node) and the binding declares the root cJSON *my_data = _n0;.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

RECORD resolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member); ERROR keeps the CVal-union default.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = 1
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
int_field: str = 'i'
integer_format: IntegerFormats = <class 'str'>
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

key_field: str = 'k'
language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

map_field: str = 'm'
max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

module_name: str = 'Module'
module_name_case: ClassVar[IdentifierCase] = 'snake'
property null_literal: str

Literal representing None.

Bare NULL under RECORD (a clean const void * record field); _format_entry re-wraps it for CVal contexts.

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'c'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (C needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (C needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}})', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

Under RECORD the asymmetric ((CVal){.a = (CVal[]){}}) wrapper is dropped: every list is a (CVal[]){...} / {...} initializer closing with a single } (a record field or a struct array, never a free-standing CVal), so the close pairs with _record_sequence_open.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}})', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ('#include <math.h>',)
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
property static_preamble: Sequence[str]

Static preamble lines emitted once per file.

Under json_type=CJSON the cJSON header replaces the default CVal / CKV type declarations: every value is a cJSON * node built with the library’s own constructors.

string_field: str = 's'
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

property true_literal: str

Literal representing True.

Bare true under RECORD (a clean bool record field); _format_entry re-wraps it for CVal contexts.

property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

uint_field: str = 'u'
property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Raise if the spec cannot produce valid C for data.

Under json_type=CJSON a dict becomes a cJSON_CreateObject whose members are keyed by JSON object strings, so non-string dict keys are rejected.

Under the RECORD strategy a record-shaped dict renders as a (struct RecordN){...} literal (and a list whose elements are all record-shaped dicts as a struct RecordN[] array); a struct is not a CVal union member, so a record reachable only through a non-record container would have to occupy a CVal slot and cannot compile. The same walk rejects two same-shape records whose shared all-record-list field has differing lengths (the field’s fixed-size struct array is sized from the first-seen instance). Rejecting here keeps the boundary explicit rather than emitting C that fails to build (cf. the set / non-record-dict field boundary tracked in #2317). The default (ERROR) strategy is unconstrained.

value_field: str = 'v'
variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap C declaration + assignment in a function.

Reads variable_name between the declaration and the assignment so the initial value is not a dead store flagged by clang-tidy’s clang-analyzer-deadcode.DeadStores check.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a C declaration in a main function.

class literalizer.languages.CSharp(*args: object, **kwargs: object)

C# language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.CSHARPnew DateOnly(...) call, e.g. new DateOnly(2024, 1, 15).

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.CSHARPnew DateTime(...) call, e.g. new DateTime(2024, 1, 15, 12, 30, 0).

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

  • json_type – When set to json_types.SYSTEM_TEXT_JSON_NODE, render values through System.Text.Json.Nodes.JsonNode (JsonObject / JsonArray / typed scalars) instead of C#’s narrow collection types. Dates / datetimes / times switch to ISO 8601 strings (unless datetime_format is EPOCH) and the const modifier is rejected because the JSON constructors are not constant expressions.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

CSharp call style options.

NAMED = KeywordCallStyle(separator=': ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for C#.

CSHARP = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('using System;',), type_produced=<class 'datetime.date'>)
ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for C#.

CSHARP = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=('using System;',), type_produced=<class 'datetime.datetime'>)
EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DICTIONARY = _CSharpDictSpec(opener_template='new Dictionary<{key_type}, {type_name}> {{')
SORTED_DICTIONARY = _CSharpDictSpec(opener_template='new SortedDictionary<{key_type}, {type_name}> {{')
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options.

ERROR raises on any value that cannot be represented. RECORD renders each record-shaped dict (non-empty, string-keyed) as a generated positional record declared in the preamble plus a matching positional literal, rather than a homogeneous Dictionary.

ERROR = 1
RECORD = 2
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(*values)

JSON value type options for C#.

SYSTEM_TEXT_JSON_NODE = 'JsonNode'

System.Text.Json.Nodes.JsonNode, the built-in .NET JSON document object model.

Modifiers

alias of _CSharpModifiers

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for C#.

ARRAY = <function sequence_format_factory.<locals>._build>
TUPLE = <function sequence_format_factory.<locals>._build>
class SetFormats(*values)

Set type options for C#.

HASH_SET = <function set_format_factory.<locals>._build>
SORTED_SET = <function set_format_factory.<locals>._build>
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = <function _build_backslash_formatter.<locals>._format>
VERBATIM = <function format_string_verbatim_csharp>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for C#.

V10 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

Under json_type every rendered file pulls in System.Text.Json.Nodes unconditionally; the per-collection format configurations leave their preamble_lines empty so the using line is emitted here exactly once regardless of which container shapes appear in the data.

Under HeterogeneousStrategies.RECORD this emits one positional record declaration per record shape present in the data; otherwise C# needs no data-dependent preamble.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('using System;',), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=('using System;',), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

default_dict_key_type: str = 'string'
default_dict_value_type: str = 'object'
default_sequence_element_type: str = 'object'
default_set_element_type: str = 'object'
dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = _CSharpDictSpec(opener_template='new Dictionary<{key_type}, {type_name}> {{')
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

Under json_type every dict literal is wrapped in new JsonObject { ["key"] = value, ... } so it renders as a JSON object, and an empty dict widens to new JsonObject(). The using System.Text.Json.Nodes; line that powers JsonObject is contributed by data_dependent_preamble rather than from this config, so a json-mode fixture imports it exactly once regardless of how many dict literals appear.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.cs'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Callable that rewrites a formatted direct call argument.

Under json_type every call argument is cast to JsonNode? so the underlying stub receives a JSON value; under any other mode call arguments pass through unchanged.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return a new ClassName constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

json_type overrides the configured date_format with the ISO 8601 string form because the C# native DateOnly literal would not round-trip through JSON.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

json_type overrides the configured datetime_format with the ISO 8601 string form unless the user has explicitly chosen the EPOCH integer form, which remains a valid JSON number.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

Positive values above long.MaxValue are accepted as bare literals because C# infers ulong for literals without a type suffix up to ulong.MaxValue. Values below long.MinValue have no clean literal form (unary minus cannot apply to ulong), so they raise UnrepresentableIntegerError.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Format one ordered-map entry.

Under json_type an ordered map renders as a JsonObject, whose collection initializer takes KeyValuePair entries via the indexer ["key"] = value form (matching the dict renderer).

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

json_type overrides the native TimeOnly literal with the ISO 8601 string form because there is no implicit conversion from TimeOnly to JsonNode and JSON has no native time type.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

Under json_type the assigned expression is cast to JsonNode? through the same helper as the declaration form so the two halves of a combined declaration / assignment stay consistent.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

Under json_type the declaration carries an explicit JsonNode? type annotation (never var) and the right-hand side is wrapped in a (JsonNode?) cast unless the value is already a JsonObject / JsonArray literal. The per-declaration formatter rejects the const modifier because every json-mode initializer (the cast or the constructor) is a runtime expression.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

json_type relaxes scalar-type checks unconditionally, because JsonObject / JsonArray accept heterogeneous JsonNode children by construction.

RECORD resolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member); ERROR uses the static raising behavior.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = 1
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.PASCAL, IdentifierCase.CAMEL, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = (ModifierCombination(name='public_static_readonly', modifiers=frozenset({<_CSharpModifiers.PUBLIC: 'public'>, <_CSharpModifiers.READONLY: 'readonly'>, <_CSharpModifiers.STATIC: 'static'>})),)
modifiers

alias of _CSharpModifiers

property null_literal: str

Null literal for the active C# representation.

Under json_type an explicitly-typed (JsonNode?)null keeps a top-level null from ambiguously binding to a method overload (System.Text.Json.Nodes exposes implicit operators from many primitive types that a bare null literal would also match).

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

Under json_type an ordered map renders as a JsonObject; the System.Text.Json.Nodes library preserves the indexer insertion order in the rendered output, so the JSON object opener is interchangeable with the dict opener here.

pygments_name = 'csharp'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (C# needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble computed from date/datetime format.

Under json_type the using System.Text.Json.Nodes; line is contributed by data_dependent_preamble instead, so this method returns an empty per-scalar map to avoid duplicating it; dates / datetimes / times all render as ISO 8601 strings (or an epoch integer for the explicit EPOCH datetime format) and need no per-scalar import of their own.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = <function sequence_format_factory.<locals>._build>
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

Under json_type every sequence is rendered as new JsonArray { ... } (and new JsonArray() for the empty case), which accepts heterogeneous JsonNode children via the implicit conversion operators on System.Text.Json.Nodes. The using directive is contributed by data_dependent_preamble, so this config leaves its preamble_lines empty.

() parses as an invalid expression in C#; the language’s ValueTuple.Create() (or a typed empty array literal new T[] {} for the array format) is the syntactically valid empty form, so prefer it whenever an empty inner list sits beside non-empty siblings. The array empty form is a plain language-level array literal, never Array.Empty<T>(), so the array path needs no using System;.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

Under the RECORD strategy a list whose every element is a record-shaped dict renders each element as a generated RecordN literal; the typed opener would type such a list Dictionary<string, object>[] (the homogeneous-map element type) which the record literals cannot initialize. Such a list is instead opened with an implicitly-typed array new[] { so C# infers RecordN[] from the literals. Every other list keeps the typed array opener.

json_type takes precedence over the RECORD strategy: record-shaped dicts under json mode render as new JsonObject { ... } (not as RecordN literals), so their parent list must keep the json new JsonArray { opener rather than the implicitly-typed new[] { form, which would otherwise infer a JsonObject[] array that is not what json mode promises.

set_format: SetFormats = <function set_format_factory.<locals>._build>
property set_format_config: SetFormatConfig

Configuration for the chosen set format (with typed opener).

Under json_type a set renders as a new JsonArray { ... } because JSON has no native set type; the empty form widens to new JsonArray() for the same reason an empty sequence does.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = True
supports_default_dict_value_type = True
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = True
supports_default_set_element_type = True
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Validate C#-specific data / format combinations.

Under json_type only dict keys that are strings can be represented as JSON object keys, so a non-string dict key is rejected up-front rather than emitted as a [<non-string>] = ... initializer that the C# compiler would reject.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file.

Under the RECORD strategy the declaration and assignment are top-level statements that must follow the file-scope record declarations, so they are wrapped as a Main method body via wrap_in_file(); otherwise this is a no-op.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file.

When content starts with a class-field modifier keyword (one of the visibility or storage keywords that C# only accepts on class members) the declaration is placed inside a class Check body with a Main entry point.

When body_preamble carries call-stub declarations (class Foo_ { ... } and static Foo_ foo = new Foo_();) the whole file is wrapped in class Check { ...stubs... static void Main() { ...content... } }. C# requires type declarations to follow top-level statements, so stubs cannot sit before top-level calls — wrapping them as class members sidesteps that ordering rule.

Under the RECORD strategy a record literal’s var declaration would otherwise be a bare top-level statement, but the generated record declarations are emitted at file scope (by the data-dependent preamble) ahead of this output and C# forbids a top-level statement after a type declaration; such content is therefore wrapped as a Main method body inside class Check rather than left as a top-level statement (call stubs and class-field declarations keep their own wrapping).

Otherwise the content is emitted as a top-level statement, which is the only context where var declarations are valid.

class literalizer.languages.Clojure(*args: object, **kwargs: object)

Clojure language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Clojure call style options.

PREFIX_KEYWORD = PrefixCallStyle(arg_separator=' ', keyword_prefix=':')
class CommentFormats(*values)

Comment style options.

SEMICOLON = CommentConfig(prefix=';', suffix='')
class DateFormats(*values)

Date format options for Clojure.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Clojure.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

DEF = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Clojure.

VECTOR = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Clojure.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Clojure.

V1_11 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PrefixCallStyle(arg_separator=' ', keyword_prefix=':')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for Clojure’s call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix=';', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ' '
empty_dict_keys

alias of EmptyDictKey

extension = '.clj'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Raise for any {"$ref": "name"} identifier.

Clojure output is not wrapped in a function body, so symbol references require a surrounding def that cannot be injected.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.KEBAB,)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'nil'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'clojure'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Clojure needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Clojure needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.KEBAB, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Cobol(*args: object, **kwargs: object)

GnuCOBOL free-format language specification.

Data is represented as COBOL WORKING-STORAGE SECTION level items: scalars become elementary data items with VALUE clauses, and sequences / dicts become group items with 05-level sub-items.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
CJSON_PROCEDURE_SECTION: ClassVar[str] = 'PROCEDURE'

name of the statements region a json_type=CJSON wrap_in_file=False result exposes; its content belongs in a program’s PROCEDURE DIVISION.

CJSON_WORKING_STORAGE_SECTION: ClassVar[str] = 'WORKING-STORAGE'

name of the declarations region a json_type=CJSON wrap_in_file=False result exposes through sections; its content belongs in a program’s WORKING-STORAGE SECTION.

class CallStyles(*values)

Cobol call style options.

POSITIONAL = CommandCallStyle(arg_separator=' ')
class CommentFormats(*values)

Comment style options.

STAR_ANGLE = CommentConfig(prefix='*>', suffix='')
class DateFormats(*values)

Date format options for Cobol.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Cobol.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

TYPED = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(*values)

JSON value type options for COBOL.

CJSON = 'cJSON'

The cJSON library’s cJSON * dynamic JSON value, built through GnuCOBOL’s C CALL interface.

The document is rendered as a tree of cJSON_Create* CALLs composed with cJSON_AddItemTo* rather than a WORKING-STORAGE record, so arbitrary string keys, JSON booleans, real numbers, heterogeneous arrays, and the empty string are all faithful.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for COBOL.

SEQUENCE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='05 FILLER PIC X(1) VALUE SPACES.', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for COBOL.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='', empty_set='05 FILLER PIC X(1) VALUE SPACES.', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for COBOL.

V2002 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = False
call_style: CallStyles = CommandCallStyle(arg_separator=' ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='*>', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = '\n'
empty_dict_keys

alias of EmptyDictKey

extension = '.cob'
false_literal: ClassVar[str] = '"FALSE"'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Prepend BY CONTENT to each COBOL CALL argument.

Under json_type=CJSON a value is a multi-statement cJSON node tree, and COBOL has no inline call-expression form to pass one as a CALL argument, so call binding is rejected (the case is skipped, no golden emitted).

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Raise for any {"$ref": "name"} identifier.

COBOL DATA DIVISION VALUE clauses only accept literals, not identifier references, so refs are not supported.

property format_call_statement: Callable[[str], str]

Wrap a call expression as a complete COBOL CALL statement.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return nested-program stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Return the quoted COBOL program name and USING keyword.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Format one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

Under json_type=CJSON the value is rebuilt as a fresh cJSON node tree (a distinct M node prefix keeps the combined declaration+assignment form from defining a data name twice) and the existing pointer is reset to its root.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

Under json_type=CJSON the rendered record value is discarded: the data is built as a cJSON node tree (WORKING-STORAGE pointer items plus PROCEDURE DIVISION CALL statements, joined as encoded file-section regions) and the binding pointer is set to its root.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.UPPER_SNAKE,)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'SPACES'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'cobol'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (COBOL needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (COBOL needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='05 FILLER PIC X(1) VALUE SPACES.', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='', empty_set='05 FILLER PIC X(1) VALUE SPACES.', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.KEBAB, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = False
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = False
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = False
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = '"TRUE"'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap COBOL declaration and assignment in a complete program.

Under json_type=CJSON both declaration and assignment are two-region payloads: their WORKING-STORAGE halves merge into one DATA DIVISION (the declaration already declares the binding pointer; the assignment build only adds its M nodes) and their PROCEDURE halves run one after the other. The file-section markers in declaration are the reliable discriminator, so this stays a staticmethod().

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a COBOL variable declaration or call block in a program.

In variable-declaration mode (variable_name is non-empty), content goes in the DATA DIVISION and body_preamble is prepended before it. In call mode (variable_name is empty), content holds PROCEDURE DIVISION statements and body_preamble holds nested-program stubs that follow STOP RUN..

Under json_type=CJSON content is a two-region payload (see _render_cjson_payload()): its WORKING-STORAGE half supplies the node pointers and literal items and its PROCEDURE half the CALL statements that build the tree.

class literalizer.languages.CommonLisp(*args: object, **kwargs: object)

Common Lisp language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

CommonLisp call style options.

PREFIX_KEYWORD = PrefixCallStyle(arg_separator=' ', keyword_prefix=':')
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='#|', suffix=' |#')
SEMICOLON = CommentConfig(prefix=';', suffix='')
class DateFormats(*values)

Date format options for CommonLisp.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for CommonLisp.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

DEFPARAMETER = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Common Lisp.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='nil', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Common Lisp.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set='nil', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Common Lisp.

ANSI = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PrefixCallStyle(arg_separator=' ', keyword_prefix=':')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for Common Lisp’s call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix=';', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ' '
empty_dict_keys

alias of EmptyDictKey

extension = '.lisp'
false_literal: ClassVar[str] = 'nil'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Raise for any {"$ref": "name"} identifier.

Common Lisp output is not wrapped in a function body, so *name* global-variable references require a surrounding DEFPARAMETER that cannot be injected.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Format one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.KEBAB,)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'nil'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'common-lisp'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Common Lisp needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Common Lisp needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='nil', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set='nil', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.KEBAB, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 't'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Cpp(*args: object, **kwargs: object)

C++ language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.CPPstd::chrono::year_month_day literal, e.g. std::chrono::year_month_day{std::chrono::year{2024}, std::chrono::month{1}, std::chrono::day{15}}.

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.CPPstd::chrono::sys_days with time-of-day durations, e.g. std::chrono::sys_days{...} + std::chrono::hours{12} + std::chrono::minutes{30}.

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

  • json_type – When set to json_types.NLOHMANN_JSON, render values through nlohmann::json::parse over an inline JSON document instead of C++’s narrow std::vector / std::map / std::unordered_map collection types. Dict keys must be strings so they remain valid JSON object keys.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Cpp call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for C++.

CPP = DateFormatConfig(formatter=<function _format_date_cpp>, preamble_lines=('#include <chrono>',), type_produced=<class 'datetime.date'>)
ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=('#include <string>',), type_produced=<class 'str'>)
property cpp_type: str

Return the C++ type name for this date format.

class DatetimeFormats(*values)

Datetime format options for C++.

CPP = DatetimeFormatConfig(formatter=<function _format_datetime_cpp>, preamble_lines=('#include <chrono>',), type_produced=<class 'datetime.datetime'>)
EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=('#include <string>',), type_produced=<class 'str'>)
property cpp_type: str

Return the C++ type name for this datetime format.

class DeclarationStyles(*values)

Declaration style options.

AUTO = _CppDeclarationStyleConfig(supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

MAP = _DictFormatOption(config=DictFormatConfig(dict_open=<function Cpp.DictFormats.<lambda>>, close='}', format_entry=<function braced_dict_entry.<locals>._format>, empty_dict=None, preamble_lines=('#include <map>',), narrowed_open=None, supports_trailing_comma=True), opener_template='std::map<std::string, {type_name}>{{')
UNORDERED_MAP = _DictFormatOption(config=DictFormatConfig(dict_open=<function Cpp.DictFormats.<lambda>>, close='}', format_entry=<function braced_dict_entry.<locals>._format>, empty_dict=None, preamble_lines=('#include <unordered_map>',), narrowed_open=None, supports_trailing_comma=True), opener_template='std::unordered_map<std::string, {type_name}>{{')
get_config(*, type_ctx: _CppTypeCtx) DictFormatConfig

Return the dict format config with variant opener.

class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options.

C++ represents heterogeneous scalar collections with std::variant by default (ERROR); TUPLE additionally renders a fixed-length heterogeneous scalar array (a dict value or the document root, all elements scalar, spanning at least two scalar buckets) as std::make_tuple(...) typed std::tuple<...>. RECORD instead renders each record-shaped dict (non-empty, string-keyed) as a generated aggregate struct declared in the preamble plus a matching Record0{.field = value, ...} designated-initializer literal, so fields may mix scalars and containers that the homogeneous std::map cannot.

ERROR = 1
RECORD = 3
TUPLE = 2
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_tick>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal_c_style>, 'UNDERSCORE': <function format_integer_octal_c_style>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(*values)

JSON value type options for C++.

NLOHMANN_JSON = 'nlohmann::json'

The nlohmann::json dynamic JSON value type from the nlohmann/json.hpp library.

Modifiers

alias of _CppModifiers

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

AUTO = _NumericLiteralSuffixConfig(int_resolver=<function _static_int_resolver.<locals>._resolve>, formatter_wrapper=<function make_long_suffix_formatter>)
NONE = _NumericLiteralSuffixConfig(int_resolver=<function _narrowest_cpp_int_type>, formatter_wrapper=<function _identity_wrapper>)
property int_resolver: Callable[[list[int]], str]

Return the value-driven int type resolver.

wrap_integer_formatter(base: Callable[[int], str]) Callable[[int], str]

Wrap the base integer formatter.

class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for C++.

ARRAY = <function _make_array_config>
INITIALIZER_LIST = <function _make_initializer_list_config>
get_config(*, type_ctx: _CppTypeCtx) SequenceFormatConfig

Return the sequence format config for the given context.

class SetFormats(*values)

Set type options for C++.

SET = SetFormatConfig(set_open=<function Cpp.SetFormats.<lambda>>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
get_config(*, type_ctx: _CppTypeCtx) SetFormatConfig

Return the set format config with variant opener.

class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for C++.

CPP20 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Return True for ref values whose C++ type is register- trivial.

clang-tidy’s performance-move-const-arg rule (and the equivalent hicpp-move-const-arg) reports std::move on a register-trivial value as an error: the move has no effect and the wrapping is wasteful. The call site routes these refs through the non-consuming formatter so the emitted C++ compiles cleanly under --warnings-as-errors.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Build data-dependent preamble lines (variant and nullptr headers, plus <tuple> under the TUPLE strategy or the generated struct declarations under RECORD).

date_format: DateFormats = DateFormatConfig(formatter=<function _format_date_cpp>, preamble_lines=('#include <chrono>',), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_cpp>, preamble_lines=('#include <chrono>',), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = _CppDeclarationStyleConfig(supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = _DictFormatOption(config=DictFormatConfig(dict_open=<function Cpp.DictFormats.<lambda>>, close='}', format_entry=<function braced_dict_entry.<locals>._format>, empty_dict=None, preamble_lines=('#include <map>',), narrowed_open=None, supports_trailing_comma=True), opener_template='std::map<std::string, {type_name}>{{')
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.cpp'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Emit a call-argument $ref as the bare identifier.

std::move would consume the variable, which is unsafe when the caller may use it again in a later call (or after the literalize_call block). Callers opt in to consuming a specific ref by listing it in literalize_call’s consumable_refs set; in that case format_call_arg_ref_identifier_consumable is used instead and emits std::move(name).

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Wrap a consumable call-argument $ref in std::move().

Used only for refs the caller declared as consumable on literalize_call() and that appear in just one call argument, so the move cannot strand a later use.

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Wrap a {"$ref": "name"} identifier in std::move(), except for trivially-copyable scalars.

A direct copy assignment (auto my_data = my_var) triggers clang-tidy performance-unnecessary-copy-initialization when the variable is never modified, so std::move is used for container-typed refs to satisfy the linter. Applying std::move to a trivially-copyable scalar (int, bool, float) is itself a clang-tidy hicpp-move-const-arg / performance-move-const-arg warning (“has no effect; remove std::move()”), so we drop the wrapper when the caller’s ref_values identifies the ref as one of those types. When the value is unknown we keep the historical std::move form.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

Closes over the chosen date/datetime type_produced so the const auto* vs auto decision can be driven by the parsed Value rather than the rendered text.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

RECORD resolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member); TUPLE and ERROR use their static behaviors.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = 1
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE, IdentifierCase.PASCAL, IdentifierCase.CAMEL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_tick>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = (ModifierCombination(name='static_const', modifiers=frozenset({<_CppModifiers.CONST: 'const'>, <_CppModifiers.STATIC: 'static'>})),)
modifiers

alias of _CppModifiers

module_name: str = 'Module'
module_name_case: ClassVar[IdentifierCase] = 'snake'
property null_literal: str

Null literal for the active C++ representation.

numeric_literal_suffix: NumericLiteralSuffixes = _NumericLiteralSuffixConfig(int_resolver=<function _narrowest_cpp_int_type>, formatter_wrapper=<function _identity_wrapper>)
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'cpp'
record_struct_name_prefix: str = 'Record'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (C++ needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble computed from date/datetime format.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = <function _make_initializer_list_config>
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

Under the RECORD strategy a list whose every element is a record-shaped dict renders each element as a generated RecordN literal; the variant opener would type such a list std::vector<std::map<...>> (the homogeneous-map element type) which the struct literals cannot initialize. Such a list is instead opened with a bare std::vector{ so class-template argument deduction infers std::vector<RecordN> from the literals. Every other list keeps the typed variant opener.

set_format: SetFormats = SetFormatConfig(set_open=<function Cpp.SetFormats.<lambda>>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ('#include <cmath>',)
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
property static_preamble: Sequence[str]

Static preamble lines emitted once per file.

Under json_type the nlohmann/json.hpp header replaces the default <initializer_list> include because every emitted expression goes through nlohmann::json::parse().

string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = True
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Validate C++-specific data/format combinations.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap C++ declaration + assignment in a function body.

Reads variable_name between the declaration and the assignment so the initial value is not a dead store flagged by clang-tidy’s clang-analyzer-deadcode.DeadStores check.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a C++ declaration in a main function.

Under json_type the body is additionally wrapped in try { ... } catch (...) { return 1; } so the potentially-throwing nlohmann::json::parse call cannot make main itself throwing — clang-tidy’s bugprone-exception-escape check rejects an implicitly noexcept main that calls a function whose signature permits exceptions, even when the runtime flag allow_exceptions=false has been passed to suppress them.

class literalizer.languages.Crystal(*args: object, **kwargs: object)

Crystal language specification.

Parameters:

sequence_format

Which Crystal sequence type to use.

  • sequence_formats.ARRAY — array literal, e.g. [1, 2, 3].

  • sequence_formats.TUPLE — tuple literal, e.g. {1, 2, 3}.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Crystal call style options.

KEYWORD = KeywordCallStyle(separator=': ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for Crystal.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Crystal.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = <function dict_format_factory.<locals>._build>
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options.

ERROR raises for any record-shaped dict that mixes scalars with a container (Hash requires a homogeneous value type). RECORD instead renders each record-shaped dict (non-empty, string-keyed) as a generated record struct declared in the per-fixture module body plus a matching positional Record0.new(value, ...) literal, so such fields are representable.

ERROR = 1
RECORD = 2
class IntegerFormats(*values)

Integer format options.

DECIMAL = mappingproxy({'NONE': <function Crystal.IntegerFormats.<lambda>>, 'UNDERSCORE': <function format_integer_underscore>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(*values)

JSON value type options for Crystal.

JSON_ANY = 'JSON::Any'

Standard-library JSON::Any via JSON.parse(%(...)).

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Crystal.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='[] of Nil', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='Tuple.new', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Crystal.

SET = <function set_format_factory.<locals>._build>
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Crystal.

V1 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = KeywordCallStyle(separator=': ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map, prefixed with the RECORD strategy’s generated record declarations.

Crystal compiles every fixture in one crystal run invocation, so a file-scope record Record0 would collide across cases. Emitting the declarations into the body preamble (which wrap_in_file() places inside the per-fixture module, ahead of the value) scopes each RecordN to its own fixture; the declarations precede the scalar body lines so a record type is in scope before its literal.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

The RECORD strategy’s generated record declarations are not emitted here (file scope): Crystal compiles every fixture in one crystal run invocation, so a file-scope record Record0 would collide across cases. They are emitted into the per-fixture module body instead; see compute_body_preamble.

Under json_type the rendered output always passes through JSON.parse, so require "json" is contributed unconditionally.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

default_dict_key_type: str = 'String'
default_dict_value_type: str = 'String'
default_set_element_type: str = 'String'
dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = <function dict_format_factory.<locals>._build>
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

json_type renders a dict as a JSON object with ": " as the entry separator and no trailing comma; the empty form widens to {}.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.cr'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Callable that rewrites a formatted direct call argument.

Under json_type every call argument is wrapped in JSON.parse(%(...)) so the receiving proc gets a JSON::Any regardless of the underlying scalar or container shape; otherwise the rendered literal passes through unchanged.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return a Crystal ClassName.new constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

json_type always emits ISO 8601 dates so the result is a JSON string regardless of the configured date_format.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

json_type always emits ISO 8601 datetimes (JSON strings) unless the user has explicitly chosen the EPOCH form, which remains a valid JSON number.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

json_type skips the _i128 overflow fallback because the JSON spec has no integer-width annotation; out-of-range values are rejected by validate_spec_for_data() with a clear error before they reach the formatter.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

json_type uses the JSON ": " separator; the native Crystal form uses " => ".

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

Under json_type the rendered literal is wrapped in JSON.parse(%(...)); Crystal’s only declaration style is ASSIGN, so the formatter does not branch on the keyword.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

json_type overrides the configured strategy: JSON arrays and objects accept any mix of value types, so scalar-type checks are skipped unconditionally. RECORD resolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member); ERROR raises.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = 1
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <function Crystal.IntegerFormats.<lambda>>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

module_name: str = 'Check'
module_name_case: ClassVar[IdentifierCase] = 'pascal'
property null_literal: str

Null literal for the active Crystal representation.

JSON::Any mode produces JSON documents inside a JSON.parse(%(...)) wrapper, so the JSON null keyword replaces Crystal’s nil.

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

json_type reuses the JSON object form for ordered maps (JSON objects preserve insertion order in the rendered text).

pygments_name = 'crystal'
record_struct_name_prefix: str = 'Record'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Crystal needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Crystal needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='[] of Nil', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

json_type renders sequences as JSON arrays ([ ... ]) inside the outer JSON.parse(%(...)) wrapper, with no Crystal-side typing or trailing comma (the JSON spec rejects trailing commas in arrays).

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = <function set_format_factory.<locals>._build>
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

json_type renders a set as a JSON array because JSON has no native set type; the empty form widens to [] for the same reason.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = True
supports_default_dict_value_type = True
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = True
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = True
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

json_type always disables trailing commas because the JSON content embedded in JSON.parse(%(...)) is parsed against the JSON spec, which rejects trailing commas in arrays and objects.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Validate Crystal-specific data/format combinations.

Under json_type every dict key must be a string (a JSON object only admits string keys) and every integer must fit the Int64 range that Crystal’s JSON.parse exposes through JSON::Any#as_i. Strings embedded in the rendered JSON document cannot contain characters the %(...) percent literal interprets specially: \\, ", (, ), or #{; we reject those upfront with a clear error rather than letting the Crystal compiler or JSON parser fail at runtime.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap Crystal declaration + assignment in a module.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a Crystal declaration in a module.

class literalizer.languages.D(*args: object, **kwargs: object)

D language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

D call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for D.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for D.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

AUTO = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options.

ERROR keeps the default std.json.JSONValue model (a record-shaped dict that mixes scalars with a container is rendered as a homogeneous JSONValue map). RECORD instead renders each record-shaped dict (non-empty, string-keyed) as a generated struct RecordN { ... } declared in the preamble plus a matching positional Record0(value, ...) constructor literal whose fields are raw D values, so a field may mix scalars and containers that the homogeneous JSONValue map cannot. Without the JSONValue wrapper the whole value is raw; a heterogeneous scalar list, a set, an ordered map or a non-record dict has no raw D representation and raises UnrepresentableInputError (D has no JSONValue-free heterogeneous container; the cross-language decision for these is tracked in #2317).

ERROR = 1
RECORD = 2
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(*values)

JSON value type options for D.

D’s default rendering already wraps every value in std.json.JSONValue; this enum exposes that mode explicitly so the field has a named value paired with the opt-out json_type=None, which selects narrow-typed rendering (raw scalars, T[] arrays, V[K] associative arrays) and rejects inputs that cannot be expressed without the JSONValue wrapper.

STD_JSON_VALUE = 'JSONValue'

The standard-library std.json.JSONValue model (D’s default).

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for D.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='parseJSON("[]")', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for D.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='parseJSON("[]")', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for D.

V2 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

Under RECORD this is the generated struct RecordN { ... } block, emitted in dependency order so a nested record is declared before its parent.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

Under RECORD every record-shaped dict is intercepted by the shared record behavior, so any dict reaching this formatter is a non-record (empty or non-string-keyed) dict with no raw D representation; its opener rejects the input.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.d'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment binding a call result.

The call-expression counterpart of format_variable_assignment; the JSONValue / struct-constructor wrapping is dropped since the variable is already declared.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call result.

A literal binding wraps the right-hand side to encode the parsed value’s runtime type (a JSONValue(...) projection, or a positional Record0(...) struct-constructor literal under RECORD); a call’s return type is opaque to the renderer, so the call result is bound directly with a plain inferred auto declaration and no value-wrapping.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

D’s widest built-in integer types are long (signed 64-bit) and ulong (unsigned 64-bit). Positive values above long.max emit a UL-suffixed ulong literal; values below long.min or above ulong.max raise UnrepresentableIntegerError rather than emit a decimal literal the compiler rejects.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Format one ordered-map entry.

Under RECORD an ordered map has no raw D representation; ordered_map_format_config rejects it before an entry is formatted, so this JSONValue template is only ever used by the default model.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

Under RECORD or narrow-typed mode every element is a raw D literal (no JSONValue wrapper), so the entry formatter is the identity.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

Under RECORD a set has no raw D representation and set_format_config rejects it at its opener before any entry is formatted, so this formatter is only ever reached by the default JSONValue model.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

The default model wraps the value in JSONValue; under RECORD or narrow-typed mode the value is a raw D literal (a Record0(...) struct, AA literal, array or scalar) assigned directly.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

The default model wraps the value in JSONValue; under RECORD or narrow-typed mode the value is a raw D literal whose type is inferred, so a plain auto binding is emitted.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

RECORD resolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member); ERROR keeps the default JSONValue model.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = 1
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL, IdentifierCase.CAMEL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = 'JSONValue'
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

module_name: str = 'Module'
module_name_case: ClassVar[IdentifierCase] = 'snake'
null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

An ordered map is never record-eligible and has no raw D representation, so under RECORD its opener rejects the input.

pygments_name = 'd'
record_struct_name_prefix: str = 'Record'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (D needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (D needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='parseJSON("[]")', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

Under RECORD a list is a raw D array [ ... ] (no JSONValue wrapper): the opener is [ for a homogeneous or empty list and rejects a heterogeneous scalar list, the closer is ], the empty literal is [] (it coerces to any declared element type) and there is no parseJSON narrowed empty form.

Under narrow-typed mode (json_type=None) the literal is also raw [ ... ], but D’s auto cannot infer an element type for an empty literal, so an empty list is rejected at the opener alongside the heterogeneous case.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='parseJSON("[]")', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

A set has no raw D representation, so under RECORD or narrow-typed mode its opener rejects the input.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
property static_preamble: Sequence[str]

File-scope preamble.

The default ERROR JSONValue model needs import std.json;; the RECORD strategy and narrow-typed (json_type=None) mode both emit raw D values with no JSONValue reference, so neither needs the import.

string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = True
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Validate D-specific data/format combinations.

Narrow-typed mode (json_type=None) rejects empty containers up front so D’s auto is never asked to infer a type from an empty literal; the default JSONValue model renders parseJSON("[]") / parseJSON("{}") for these and needs no validation.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap D declaration + assignment in a function.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a D declaration in a main function.

class literalizer.languages.Dart(*args: object, **kwargs: object)

Dart language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.DARTDateTime.parse(...) call, e.g. DateTime.parse("2024-01-15").

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.DARTDateTime.parse(...) call, e.g. DateTime.parse("2024-01-15T12:30:00").

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Dart call style options.

NAMED = KeywordCallStyle(separator=': ')
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date formatting options for Dart.

DART = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime formatting options for Dart.

DART = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

CONST = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
FINAL = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = <class 'str'>
HEX = <function format_integer_hex>
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Dart.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback='[', uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=True, supports_trailing_comma=True, empty_sequence='()', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Dart.

SET = <function set_format_factory.<locals>._build>
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = <function _build_backslash_formatter.<locals>._format>
SINGLE = <function _build_backslash_formatter.<locals>._format>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

ALWAYS = 2
NEVER = 1
SAFE = 3
formatter(*, auto_formatter: Callable[[str, str, Value, frozenset[Enum]], str], keyword: str, date_hint: str, datetime_hint: str, default_set_element_type: str, default_dict_key_type: str, default_dict_value_type: str, sequence_is_tuple: bool) Callable[[str, str, Value, frozenset[Enum]], str]

Return the variable declaration formatter.

class VersionFormats(*values)

Version options for Dart.

V3 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = KeywordCallStyle(separator=': ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

default_dict_key_type: str = 'String'
default_dict_value_type: str = 'dynamic'
default_set_element_type: str = 'dynamic'
dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.dart'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Format one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = <class 'str'>
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'dart'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Dart needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Dart needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback='[', uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = <function set_format_factory.<locals>._build>
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = True
supports_default_dict_value_type = True
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = True
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Raise if the spec cannot produce valid code for data.

Dart’s DART date / datetime formats render as DateTime.parse(...), which is a runtime call and not a constant expression, so they are incompatible with CONST.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file.

class literalizer.languages.Dhall(*args: object, **kwargs: object)

Dhall language specification.

Produces Dhall values — records for mappings, and lists for sequences and sets — following Dhall syntax.

Dhall is a programmable configuration language that is not Turing-complete. It supports records ({ key = value }), lists ([1, 2, 3]), Text, Natural, Double, and Bool types.

Dhall has no null type; null values are rendered as the empty string "".

Dates and datetimes are rendered as quoted ISO 8601 strings because Dhall has no native date type.

Dict keys that cannot be represented as Dhall backtick-quoted labels raise InvalidDictKeyError. This includes empty keys and keys containing control characters or backticks, since Dhall labels only allow printable ASCII.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Dhall call style options.

POSITIONAL = PositionalCallStyle(arg_separator=' ', parenthesize_each_arg=True)
class CommentFormats(*values)

Comment style options.

LINE = CommentConfig(prefix='--', suffix='')
class DateFormats(*values)

Date format options for Dhall.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Dhall.

EPOCH = DatetimeFormatConfig(formatter=<function datetime_epoch_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

Dhall backtick-quoted labels must be non-empty and contain only printable ASCII, so unsupported dict keys always raise InvalidDictKeyError.

ERROR = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Strategy for representing dicts or lists whose scalar values span more than one Dhall type.

ERROR = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)

Raise HeterogeneousScalarCollectionError (or HeterogeneousSiblingListsError) when scalar values of mixed types appear in a container that cannot represent them. This is the default, matching Dhall’s strict-typing convention.

UNION_TYPE = _HeterogeneousStrategyConfig(build_behavior=<function _build_union_type_behavior>, build_preamble=<function _build_union_type_preamble>)

Auto-generate a Dhall union type in the preamble containing only the variants actually present in the data, and wrap each heterogeneous scalar value as {UnionName}.{Variant} payload.

The union name is configurable via Dhall.heterogeneous_value_union_name (default "Value").

class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Dhall.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=False, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='[] : List {}', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=True, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Dhall.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set='[] : List {}', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Dhall.

V17 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=' ', parenthesize_each_arg=True)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='--', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

For HeterogeneousStrategies.UNION_TYPE emits a let binding declaring a union type containing only the variants actually used in heterogeneous positions in the data. Other strategies produce no preamble.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = False
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.dhall'
false_literal: ClassVar[str] = 'False'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Wrap each scalar call argument in the DVal union tag.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return the DVal union-type preamble for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Raise for any $ref argument.

Dhall’s stub parameter type is DVal; a ref variable holds a concrete type that Dhall’s type-checker cannot unify with it.

property format_call_statement: Callable[[str], str]

Validate and wrap a call expression as a let _ = binding.

Raises CallArgNotSupportedError if the rendered call contains a function application without the required whitespace, or more than one positional argument.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment
property format_call_variable_declaration
static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Format one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the behavior for the chosen heterogeneous strategy.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)
heterogeneous_value_union_name: str = 'Value'
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL)
indent: str = '  '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = '""'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name: ClassVar[str | None] = None
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Dhall needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Dhall needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=False, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='[] : List {}', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=True, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set='[] : List {}', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = False
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'True'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Join declarations and calls into a Dhall let-chain.

Delegates to wrap_in_file() with an empty variable name, which appends the in {=} terminator needed by both this path and the wrap_in_file=True call path.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid Dhall file.

When variable_name is empty the call is from a call context (either wrap_calls_with_declarations() or literalize_call() with wrap_in_file=True); both need a closing in {=} to complete the let-chain into a valid Dhall expression. When variable_name is set the call is from a regular literalize() path whose content already ends with the in <varname> clause produced by the variable form.

class literalizer.languages.Elixir(*args: object, **kwargs: object)

Elixir language specification.

Parameters:
  • date_format

    Which date format to use.

    • date_formats.ISO — ISO 8601 string literal, e.g. "2024-01-15".

    • date_formats.ELIXIR — Elixir ~D sigil, e.g. ~D[2024-01-15].

  • datetime_format

    Which datetime format to use.

    • datetime_formats.ISO — ISO 8601 string literal, e.g. "2024-01-15T12:30:00+00:00".

    • datetime_formats.ELIXIR — Elixir ~U sigil for timezone-aware datetimes (e.g. ~U[2024-01-15 12:30:00+00:00]) or ~N sigil for naive datetimes (e.g. ~N[2024-01-15 12:30:00]).

  • sequence_format

    Which Elixir sequence type to use.

    • sequence_formats.LIST — list literal, e.g. [1, 2, 3].

    • sequence_formats.TUPLE — tuple literal, e.g. {1, 2, 3}.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Elixir call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for Elixir.

ELIXIR = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Elixir.

ELIXIR = DatetimeFormatConfig(formatter=<function _format_datetime_elixir>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Elixir.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Elixir.

MAP_SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='MapSet.new()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Elixir.

V1_14 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Return the call style configuration.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.ex'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'nil'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'elixir'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Elixir needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Elixir needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='MapSet.new()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_call_variable_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a call-result variable binding in an Elixir module.

wrap_in_file()’s variable branch places body_preamble inside def x do, but for a call binding those lines are the module-level stub function definitions emitted by _elixir_call_stub(); nesting a def inside def x do is a syntax error. This hook hoists the def ``-prefixed preamble lines to module scope (matching the call-without-binding branch of :meth:`wrap_in_file`) while keeping the ``my_data = make_widget(...) binding, any non-stub preamble lines (e.g. the dotted-call root = RootType_ alias), and the trailing _ = my_data use inside def x do.

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap an Elixir variable assignment in a module function.

For variable cases, body_preamble lines are prepended inside def x do. For call cases (empty variable_name), lines starting with def `` are lifted to module level inside ``defmodule Check do but before def x do, while other preamble lines stay inside def x do.

class literalizer.languages.Elm(*args: object, **kwargs: object)

Elm language specification.

The generated output uses custom constructors (ENull, EBool, EList, EDict, ESet) that are not built-in Elm types. To compile the generated code, define a Val custom type in the consuming module:

type Val
    = ENull
    | EBool Bool
    | EInt Int
    | EFloat Float
    | EStr String
    | EList (List Val)
    | EDict (List ( String, Val ))
    | ESet (List Val)

The body preamble automatically emits only the constructors that are actually used by the data.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.ISO — ISO 8601 string, e.g. EStr "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.ISO — ISO 8601 string, e.g. EStr "2024-01-15T12:30:00".

  • type_name – Name of the generated custom type. Defaults to "Val".

  • constructor_prefix – Prefix for generated constructor names. Defaults to "E", producing constructors like ENull, EBool, EInt, etc.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function _build_elm_bytes_base64.<locals>._format>
HEX = <function _build_elm_bytes_hex.<locals>._format>
class CallStyles(*values)

Elm call style options.

CURRIED = CommandCallStyle(arg_separator=' ')
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='{-', suffix=' -}')
DOUBLE_DASH = CommentConfig(prefix='--', suffix='')
class DateFormats(*values)

Date format options for Elm.

ISO = DateFormatConfig(formatter=<function _build_elm_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Elm.

EPOCH = DatetimeFormatConfig(formatter=<function datetime_epoch_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function _build_elm_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function _build_elm_float_wrapper.<locals>._format>
REPR = <function _build_elm_float_wrapper.<locals>._format>
SCIENTIFIC = <function _build_elm_float_wrapper.<locals>._format>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = <function _build_elm_integer_formatter.<locals>._format>
HEX = <function _build_elm_integer_formatter.<locals>._format>
class JsonTypes(*values)

JSON value type options for Elm.

JSON_ENCODE_VALUE = 1

Render values directly as elm/json Json.Encode.* calls producing Json.Encode.Value.

With this mode the generated module contains no Val ADT and no walker: every literal is an idiomatic Json.Encode.bool, Json.Encode.int, Json.Encode.string, Json.Encode.list identity [ ... ], Json.Encode.object [ ( "k", ... ) ] etc., and feeds straight into Json.Encode.encode 0 for serialization.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Elm.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Elm.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Elm.

V0_19 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function _build_elm_bytes_hex.<locals>._format>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = CommandCallStyle(arg_separator=' ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for Elm’s call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='--', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines.

Under json_type the preamble is a single import Json.Encode line; otherwise the per-fixture Val ADT declaration is emitted with only the constructors actually referenced by the data.

constructor_prefix: str = 'E'
property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function _build_elm_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _build_elm_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

Under json_type dicts render as Json.Encode.object [ ( "k", v ) ] rather than the ADT {prefix}Dict [ ( "k", v ) ] form.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.elm'
property false_literal: str

Literal representing False.

float_format: FloatFormats = <function _build_elm_float_wrapper.<locals>._format>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Wrap each formatted call argument in parentheses.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

Under json_type the stub returns Json.Encode.Value (and defaults to Json.Encode.null) so the bound call type-checks against the Json.Encode.Value annotation on the enclosing declaration.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite call target parts into an Elm identifier.

The first character of each part after the first is upper-cased and the parts are concatenated (e.g. ["app", "client", "fetch"] becomes appClientFetch).

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call expression.

The literal-binding declaration is prepended with a name : Val annotation derived from the bound value’s runtime tagged-enum type; a call expression has no such tag, so the annotation is omitted and Elm infers the call’s return type instead.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

Under json_type the annotation is the flat Json.Encode.Value regardless of whether the top-level shape is a list, dict, set, or scalar; every literal flows through the same Json.Encode.* constructor pipeline.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = True
integer_format: IntegerFormats = <function _build_elm_integer_formatter.<locals>._format>
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

property null_literal: str

Literal representing None.

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'elm'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Elm needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Elm needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

Under json_type sets render as a JSON array (Json.Encode.list identity [...]) because JSON has no set type; otherwise the configured ADT {prefix}Set [...] form applies.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = False
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = False
supports_variable_names = True
supports_zero_parameter_calls = False
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

property true_literal: str

Literal representing True.

property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

type_name: str = 'Val'
property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Validate Elm-specific data/format combinations.

Under json_type every dict key must be a string because Json.Encode.object only admits string keys.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_call_variable_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a call-result variable binding in an Elm module.

The literal-binding scaffold emits a top-level name : Val / name = pair that the test driver forces externally via a Check.my_data reference. A call-mode fixture is instead driven through Check.main, so the binding is placed inside the main let block; evaluating the block forces the call. content is the single-line name = call binding produced by format_call_variable_declaration.

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Wrap Elm declarations and call expressions in a module.

Both variable declarations and call statements are placed inside a let block so the generated file is a valid Elm module. Declarations are indented without a _ = prefix; call statements are bound via _ = to satisfy Elm’s requirement that every let binding produces a value. calls is one single-line call expression per line: this is the only shape literalize_call produces for Elm, which uses CollectionLayout.COMPACT for wrapped calls and rejects standalone comments in that path.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap an Elm value declaration in a module.

When variable_name is empty (call mode), each call expression in content is bound via _ = inside a let block so the generated file is syntactically valid Elm. content is one single-line call expression per line: this is the only shape literalize_call produces for Elm, which uses CollectionLayout.COMPACT for wrapped calls and rejects standalone comments in that path.

class literalizer.languages.Erlang(*args: object, **kwargs: object)

Erlang language specification.

Parameters:
  • date_format

    Which date format to use.

    • date_formats.ISO — ISO 8601 string literal, e.g. "2024-01-15".

    • date_formats.ERLANG — Erlang date tuple, e.g. {2024, 1, 15}.

  • datetime_format

    Which datetime format to use.

    • datetime_formats.ISO — ISO 8601 string literal, e.g. "2024-01-15T12:30:00+00:00".

    • datetime_formats.ERLANG — Erlang datetime tuple, e.g. {{2024, 1, 15}, {12, 30, 0}}.

  • sequence_format

    Which Erlang sequence type to use.

    • sequence_formats.LIST — list literal, e.g. [1, 2, 3].

    • sequence_formats.TUPLE — tuple literal, e.g. {1, 2, 3}.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
BINARY = <function _format_bytes>
class CallStyles(*values)

Erlang call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

PERCENT = CommentConfig(prefix='%', suffix='')
class DateFormats(*values)

Date format options for Erlang.

ERLANG = DateFormatConfig(formatter=<function _format_date_erlang>, preamble_lines=(), type_produced=<class 'datetime.date'>)
ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Erlang.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ERLANG = DatetimeFormatConfig(formatter=<function _format_datetime_erlang>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

BINARY = <function format_integer_binary_erlang>
DECIMAL = <class 'str'>
HEX = <function format_integer_hex_erlang>
class JsonTypes(*values)

JSON value type options for Erlang.

OTP_JSON = 1

Erlang’s built-in json module (OTP_27 and later).

Renders strings, ISO dates / datetimes / times, and bytes (base64-encoded) as UTF-8 binary literals so json:encode/1 accepts the value directly. Null is emitted as the bare atom null; sets render as JSON arrays. Dict keys must be strings (validated upfront).

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Erlang.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Erlang.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='sets:from_list([])', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Erlang.

OTP_25 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function _format_bytes>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for Erlang’s call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='%', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.erl'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Capitalize a {"$ref": "name"} identifier so the call site references the declared Erlang variable.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE,)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = <class 'str'>
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

module_name: str = 'Module'
module_name_case: ClassVar[IdentifierCase] = 'snake'
property null_literal: str

null under OTP_JSON, undefined otherwise.

Erlang’s json:encode/1 rejects the bare atom undefined (it is not in the documented set of accepted scalars) but encodes null as JSON null.

Type:

Null literal

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'erlang'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Erlang needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Erlang needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='sets:from_list([])', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ','
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = False
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = False
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Validate Erlang-specific data/format combinations.

Under json_type every dict key must be a string so the rendered map keys (UTF-8 binaries) match what Erlang’s json:encode/1 expects.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_call_variable_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a call-result variable binding in an Erlang module.

wrap_in_file()’s variable branch places body_preamble inside x(), but for a call binding those lines are the module-level stub function definitions emitted by _erlang_call_stub(); nesting a function definition inside the x/0 clause is a syntax error. This hook hoists body_preamble to module scope between -export and x() (matching the call-without-binding branch of wrap_in_file()) while keeping the My_data = make_widget(...) binding and the trailing My_data. return inside x().

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap an Erlang snippet in a module function.

For the variable form, body_preamble lines are prepended inside x() and the function returns the bound variable. For the call form (empty variable_name), body_preamble lines are treated as module-level function definitions placed between -export and x(); the call statements in content are terminated with , via statement_terminator and the trailing , is rewritten to . so x() ends on a valid clause.

class literalizer.languages.FSharp(*args: object, **kwargs: object)

F# language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.FSHARPSystem.DateOnly(...) call, e.g. System.DateOnly(2024, 1, 15).

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.FSHARPSystem.DateTime(...) call, e.g. System.DateTime(2024, 1, 15, 12, 30, 0).

  • type_name – Name of the generated custom type. Defaults to "Val".

  • constructor_prefix – Prefix for generated constructor names. Defaults to "F", producing constructors like FNull, FBool, FInt, etc.

  • json_type – When set to json_types.SYSTEM_TEXT_JSON_NODE, render values through System.Text.Json.Nodes.JsonNode (JsonObject / JsonArray / JsonValue.Create) instead of the generated tagged Val discriminated union. Dates / datetimes / times switch to ISO 8601 strings (unless datetime_format is EPOCH), heterogeneous collections are accepted, and non-string dict keys are rejected because JSON object keys must be strings.

Notes

The default tagged Val discriminated union does not round-trip through System.Text.Json.JsonSerializer.Serialize (with or without FSharp.SystemTextJson) without a custom JsonConverter<Val>. Two pitfalls:

  • The map case is emitted as FMap of (string * Val) list, a tuple list rather than a Map<,>, so that insertion order survives (F#’s built-in Map<,> is sorted by key). A generic JSON encoder emits it as [[k, v], ...] instead of {"k": v}.

  • FSharp.SystemTextJson’s Untagged encoding ignores UnwrapSingleFieldCases, so FInt 42L round-trips as {"Item": 42} rather than 42 (upstream behavior reproduced on 1.3.13 and 1.4.36).

Users serializing Val to JSON must walk the constructors explicitly; selecting json_type=SYSTEM_TEXT_JSON_NODE avoids the Val union entirely so a single .ToJsonString() call round-trips the rendered value.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

FSharp call style options.

CURRIED = CommandCallStyle(arg_separator=' ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='(*', suffix=' *)')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for FSharp.

FSHARP = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for FSharp.

EPOCH = DatetimeFormatConfig(formatter=<function _build_fsharp_datetime_epoch.<locals>._format>, preamble_lines=(), type_produced=<class 'int'>)
FSHARP = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
LET_MUTABLE = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

BINARY = <function format_integer_binary>
DECIMAL = <class 'str'>
HEX = <function format_integer_hex>
OCTAL = <function format_integer_octal>
class JsonTypes(*values)

JSON value type options for F#.

SYSTEM_TEXT_JSON_NODE = 'JsonNode'

System.Text.Json.Nodes.JsonNode, the built-in .NET JSON document object model.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for F#.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='|]', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val array', narrowed_empty_form=None)
LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)
class SetFormats(*values)

Set type options for F#.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for F#.

V8 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

Under json_type the file always open``s the ``System.Text.Json.Nodes types inside the module body so the JsonObject / JsonArray / JsonValue constructors resolve; the F# module declaration must be the first non-blank line, which rules out the file-level preamble that other languages use for an equivalent import.

Swaps int64 to bigint in the FInt variant when the data contains an integer outside signed 64-bit range.

constructor_prefix: str = 'F'
property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = '; '
empty_dict_keys

alias of EmptyDictKey

extension = '.fs'
property false_literal: str

Literal representing False.

float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Callable that rewrites a formatted direct call argument.

Curried calls parenthesize each argument so that constructor applications are not parsed as additional arguments to the outer call. Under json_type every argument is wrapped as a JsonNode (via JsonValue.Create and an explicit :> JsonNode widening cast) so the underlying stub receives a JSON value.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment binding a call expression.

The literal-binding assignment injects a : Val annotation and a tagged-enum constructor derived from the bound value’s runtime type; a call expression has no such tag, so both are omitted and F# infers the return type. Mirrors format_variable_assignment, which always emits a plain let (never let mutable) regardless of declaration_style: an F# rebinding shadows with let, so the mutable keyword would be spurious here.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call expression.

The literal-binding declaration adds a leading name: Val type annotation and wraps the value in a tagged-enum constructor (FInt, FStr, …) derived from the bound value’s runtime type; a call expression has no such tag, so both the annotation and the constructor wrapper are omitted and F# infers the call’s return type instead.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

Under json_type the EPOCH branch emits a bare int64 literal (e.g. 1705320600L) rather than the tagged FInt ... constructor used outside json mode: the Val discriminated union does not exist under json_type, and the entry / top-level formatter is responsible for wrapping the literal with JsonValue.Create so it becomes a JsonNode.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

Under json_type integers carry an explicit F# suffix (L for signed-64-bit, UL for values one beyond Int64.MaxValue up through UInt64.MaxValue) so the JsonValue.Create overload set can resolve unambiguously to long / ulong. Negative values below Int64.MinValue and positive values above UInt64.MaxValue have no JsonValue.Create overload and are rejected up-front rather than emitted as a literal F# would refuse to compile.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Callable that formats one sequence entry.

property format_set_entry: Callable[[Value, str], str]

Callable that formats one set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

json_type relaxes scalar-type checks unconditionally because JsonObject / JsonArray accept heterogeneous JsonNode children by construction.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = <class 'str'>
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

module_name: str = 'Module'
module_name_case: ClassVar[IdentifierCase] = 'pascal'
property null_literal: str

Literal representing None.

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'fsharp'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble with type declarations.

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

property true_literal: str

Literal representing True.

property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

type_name: str = 'Val'
property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Validate F#-specific data / format combinations.

Under json_type only dict keys that are strings can be represented as JSON object keys, so a non-string dict key is rejected up-front.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap F# declaration + assignment in separate private functions.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap an F# let declaration in a module.

class literalizer.languages.Forth(*args: object, **kwargs: object)

Forth language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function _format_bytes_base64_forth>
HEX = <function _format_bytes_hex_forth>
class CallStyles(*values)

Forth call style options.

POSTFIX = PostfixCallStyle(arg_separator=' ')
class CommentFormats(*values)

Comment style options.

BACKSLASH = CommentConfig(prefix='\\', suffix='')
PAREN = CommentConfig(prefix='(', suffix=' )')
class DateFormats(*values)

Date format options.

ISO = DateFormatConfig(formatter=<function _format_date_forth>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function _format_datetime_forth>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

COLON = DeclarationStyleConfig(formatter=<function _format_forth_declaration>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

REPR = <function _format_float_forth>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=' -arr', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='+arr -arr', preamble_lines=(), format_entry=<function _forth_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=' -arr', empty_set='+arr -arr', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

NONE = 1
class StringFormats(*values)

String format options.

ESCAPED = <function _format_string_forth>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Forth.

ANS = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function _format_bytes_hex_forth>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style_config: ClassVar[PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle | CallSupport] = PostfixCallStyle(arg_separator=' ')
call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='\\', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function _format_date_forth>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_forth>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_forth_declaration>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ' '
empty_dict_keys

alias of EmptyDictKey

extension = '.fth'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function _format_float_forth>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Format one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.UPPER_SNAKE, IdentifierCase.SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = '0'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'forth'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Forth needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Forth needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=' -arr', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='+arr -arr', preamble_lines=(), format_entry=<function _forth_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=' -arr', empty_set='+arr -arr', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = <function _format_string_forth>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = False
supports_collection_comments: ClassVar[bool] = False
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Fortran(*args: object, **kwargs: object)

Fortran language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Fortran call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

EXCLAMATION = CommentConfig(prefix='!', suffix='')
class DateFormats(*values)

Date format options for Fortran.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Fortran.

EPOCH = DatetimeFormatConfig(formatter=<function _format_fortran_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

TYPED = DeclarationStyleConfig(formatter=<function _build_format_variable_declaration.<locals>._format_variable_declaration>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

Every finite literal is emitted with the _real64 kind suffix so that values like 1.7976931348623157e+308 (which exceed the default single-precision real range) parse correctly and so that 3.14 is not silently rounded to single precision before being passed to the freal(real(real64)) constructor declared in static_body_preamble.

FIXED = <function _suffix_real64.<locals>._suffixed>
REPR = <function _suffix_real64.<locals>._suffixed>
SCIENTIFIC = <function _suffix_real64.<locals>._suffixed>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Fortran.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Fortran.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Fortran.

  • VersionFormats.V2003 — target Fortran 2003; the int64 and real64 kinds are defined locally via selected_int_kind / selected_real_kind because Fortran 2003’s iso_fortran_env has no such named constants.

  • VersionFormats.V2008 — target Fortran 2008; the int64 and real64 kinds are imported from the intrinsic iso_fortran_env module.

V2003 = 1
V2008 = 2
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bool_name: str = 'fbool'
bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='!', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _build_format_variable_declaration.<locals>._format_variable_declaration>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

entry_name: str = 'fentry'
extension = '.f90'
property false_literal: str

Literal representing False.

float_format: FloatFormats = <function _suffix_real64.<locals>._suffixed>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Wrap a call argument in the appropriate fval_t constructor.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Prepend the Fortran call keyword to each call statement.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment binding a call result.

The call-expression counterpart of format_variable_assignment; the fval_t-constructor wrapping is dropped since the call already yields a type(fval_t).

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call result.

A literal binding wraps the right-hand side in a fval_t constructor chosen from the parsed literal’s type; a call’s return type is opaque to the renderer and is always type(fval_t) (the type every generated call stub returns), so the call result is bound directly to a plain type(fval_t) declaration with no constructor wrapping.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as an int64 Fortran literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Callable that formats one sequence entry.

property format_set_entry: Callable[[Value, str], str]

Callable that formats one set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
int_name: str = 'fint'
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 2
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

list_name: str = 'flist'
map_name: str = 'fmap'
max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

module_name: str = 'Module'
module_name_case: ClassVar[IdentifierCase] = 'snake'
property null_literal: str

Literal representing None.

null_name: str = 'fnull'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'fortran'
real_name: str = 'freal'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Fortran needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Fortran needs none).

static sequence_binding_declarations(declarations: tuple[str, ...]) str

Order Fortran binding declarations for variable-mode wrapping.

Each binding’s bare_code is a type(fval_t) :: name specification line followed by an assignment. Fortran requires every specification statement to precede every executable statement, so the type-declaration lines are gathered first and the assignment lines follow, across all bindings including the final result binding.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

set_name: str = 'fset'
skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ('  use, intrinsic :: ieee_arithmetic',)
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

property static_body_preamble: Sequence[str]

Static body-preamble lines emitted once per file.

Fortran 2008 imports the int64 and real64 kinds from the intrinsic iso_fortran_env module. Those named constants did not exist in Fortran 2003’s iso_fortran_env, so the 2003 target instead defines equivalent kind parameters with selected_int_kind(18) (18 decimal digits selects the same 8-byte integer kind int64 denotes) and selected_real_kind(15, 307) (15 decimal digits + a 10**307 range selects the IEEE 754 binary64 kind real64 denotes). Fortran requires implicit none before any data declaration, so the 2003 parameters follow it whereas the 2008 use precedes it. Either way the rest of the module, including the _int64 and _real64 literal suffixes, refers to the kinds by name, so nothing else varies by version.

property static_preamble: Sequence[str]

Static preamble lines emitted once per file.

str_name: str = 'fstr'
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = False
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

property true_literal: str

Literal representing True.

property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_call_variable_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a call-result variable binding in a Fortran program.

The literal-binding wrap_in_file() variable branch places body_preamble directly in the program body, but a call stub (an internal function/subroutine) cannot be a plain executable statement: it must live in the contains section after the executable statements. content already carries the type(fval_t) :: name specification line followed by the binding assignment in the order Fortran requires, so this delegates to the empty-variable_name (call-mode) branch of wrap_in_file(), which places content in the program body and the stubs in contains.

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Wrap Fortran call stubs and variable declarations alongside calls.

Fortran requires all specification statements (type declarations) to precede executable statements (assignments and calls). Each declaration bare_code from literalize() is a two-part string: a type(fval_t) :: name declaration on the first line and an assignment on the remaining lines. This method splits them so that all type-declaration lines appear before any assignment or call lines, producing a valid program.

Call stubs are placed in the contains section via wrap_in_file().

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap Fortran declaration + assignment in separate subroutines.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a Fortran variable declaration or call block in a program.

When variable_name is non-empty (variable declaration mode), body_preamble is prepended before content in the program body. When variable_name is empty (call mode), body_preamble holds internal-procedure stubs that go in the contains section after the executable statements in content.

class literalizer.languages.Gleam(*args: object, **kwargs: object)

Gleam language specification.

The generated output uses custom constructors (GNull, GBool, GList, GDict, GSet) that are not built-in Gleam types. To compile the generated code, a GVal custom type is emitted in the body preamble, containing only the constructors actually used by the data. For example, data consisting solely of an integer yields:

pub type GVal {
  GInt(Int)
}
Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.ISO — ISO 8601 string, e.g. GStr("2024-01-15").

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.ISO — ISO 8601 string, e.g. GStr("2024-01-15T12:30:00").

  • sequence_format

    Which Gleam sequence type to use.

    • sequence_formats.LIST — list literal, e.g. GList([GInt(1), GInt(2), GInt(3)]).

    • sequence_formats.TUPLE — tuple literal, e.g. #(GInt(1), GInt(2), GInt(3)).

  • type_name – Name of the generated custom type. Defaults to "GVal".

  • constructor_prefix – Prefix for generated constructor names. Defaults to "G", producing constructors like GNull, GBool, GInt, etc.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function _build_gleam_bytes_base64.<locals>._format>
HEX = <function _build_gleam_bytes_hex.<locals>._format>
class CallStyles(*values)

Gleam call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for Gleam.

ISO = DateFormatConfig(formatter=<function _build_gleam_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Gleam.

EPOCH = DatetimeFormatConfig(formatter=<function datetime_epoch_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function _build_gleam_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function _build_gleam_float_wrapper.<locals>._format>
REPR = <function _build_gleam_float_wrapper.<locals>._format>
SCIENTIFIC = <function _build_gleam_float_wrapper.<locals>._format>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function _build_gleam_integer_wrapper.<locals>._format>, 'UNDERSCORE': <function _build_gleam_integer_wrapper.<locals>._format>})
DECIMAL = mappingproxy({'NONE': <function _build_gleam_integer_wrapper.<locals>._format>, 'UNDERSCORE': <function _build_gleam_integer_wrapper.<locals>._format>})
HEX = mappingproxy({'NONE': <function _build_gleam_integer_wrapper.<locals>._format>, 'UNDERSCORE': <function _build_gleam_integer_wrapper.<locals>._format>})
OCTAL = mappingproxy({'NONE': <function _build_gleam_integer_wrapper.<locals>._format>, 'UNDERSCORE': <function _build_gleam_integer_wrapper.<locals>._format>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(*values)

JSON value type options for Gleam.

GLEAM_JSON_JSON = 'gleam/json.Json'

The gleam_json package’s Json builder type.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Gleam.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='#()', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Gleam.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

NONE = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Gleam.

V1 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function _build_gleam_bytes_hex.<locals>._format>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for Gleam’s call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

constructor_prefix: str = 'G'
property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return the pub type declaration tailored to data.

Under json_type the rendered values flow through the gleam_json builder API and no GVal ADT is needed, so the preamble is empty.

date_format: DateFormats = DateFormatConfig(formatter=<function _build_gleam_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _build_gleam_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

Under json_type dicts are rendered as json.object([#("k", v), ...]) builder calls; the entry formatter strips the json.string(...) wrapping the key formatter applied so each pair’s key is a bare string literal.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.gleam'
property false_literal: str

Literal representing False.

float_format: FloatFormats = <function _build_gleam_float_wrapper.<locals>._format>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

Non-finite values raise UnrepresentableSpecialFloatError because Gleam’s Erlang target has no expression that evaluates to a non-finite float.

The redundant + Python’s repr emits on positive exponents (1.0e+16) is stripped because Gleam’s parser rejects it with This float is missing an exponent.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

Under json_type the assignment also carries the : json.Json annotation so a shadowed binding keeps the builder static type explicit.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

Under json_type the binding carries an explicit : json.Json annotation so the static type matches the gleam_json builder’s return type and downstream encoders like json.to_string resolve without inference.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

Under json_type every value is wrapped in a json.Json builder call so scalar uniformity is irrelevant across container elements.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE,)
indent: str = '  '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <function _build_gleam_integer_wrapper.<locals>._format>, 'UNDERSCORE': <function _build_gleam_integer_wrapper.<locals>._format>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

property null_literal: str

Literal representing None.

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'gleam'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Gleam needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Gleam needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

Under json_type sequences are rendered as json.preprocessed_array([...]) builder calls since each element is already a json.Json value; the typed json.array(of:) overload would require a uniform element encoder which the heterogeneous-input case cannot supply.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

Under json_type sets become json.preprocessed_array([...]) builder calls; JSON has no set type so the closest builder is the heterogeneous array constructor.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
property static_preamble: Sequence[str]

File-scope preamble.

Under json_type an import gleam/json line is added so the rendered builder calls resolve. The default GVal ADT mode needs no static preamble; its tagged ADT declaration is emitted by data_dependent_preamble instead.

string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = False
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = False
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

property true_literal: str

Literal representing True.

property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

type_name: str = 'GVal'
property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap Gleam declaration + assignment in a main function.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a Gleam let binding in a main function.

class literalizer.languages.Go(*args: object, **kwargs: object)

Go language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.GOtime.Date call, e.g. time.Date(2024, time.January, 15, 0, 0, 0, 0, time.UTC).

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.GOtime.Date call, e.g. time.Date(2024, time.January, 15, 12, 30, 0, 0, time.UTC).

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Go call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for Go.

GO = DateFormatConfig(formatter=<function _format_date_go>, preamble_lines=('import "time"',), type_produced=<class 'datetime.date'>)
ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Go.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
GO = DatetimeFormatConfig(formatter=<function _format_datetime_go>, preamble_lines=('import "time"',), type_produced=<class 'datetime.datetime'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

SHORT = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Strategy for dicts whose values span more than one Go type.

ERROR keeps Go’s strict-typing behavior (mixed-value dicts that cannot be represented raise). RECORD renders each record-shaped dict (non-empty, string-keyed) as a generated struct declared in the preamble plus a matching struct literal, so fields may legitimately mix scalars and containers.

ERROR = 1
RECORD = 2
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

AUTO = 2
NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Go.

SLICE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Go.

SET = <function set_format_factory.<locals>._build>
class StatementTerminatorStyles(*values)

Statement terminator options.

NONE = ''
property statement_terminator: str

Terminator appended to complete call statements.

class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Go.

V1_18 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

For HeterogeneousStrategies.RECORD emits one struct declaration per record shape present in the data; otherwise produces no preamble.

date_format: DateFormats = DateFormatConfig(formatter=<function _format_date_go>, preamble_lines=('import "time"',), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_go>, preamble_lines=('import "time"',), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

default_dict_key_type: str = 'string'
default_dict_value_type: str = 'any'
default_ordered_map_value_type: str = 'any'
default_sequence_element_type: str = 'any'
default_set_element_type: str = 'any'
dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.go'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return a Go NewClassName constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the behavior for the chosen heterogeneous strategy.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = 1
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.PASCAL, IdentifierCase.CAMEL)
indent: str = '\t'
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'nil'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'go'
record_shape_names: Mapping[frozenset[str], str]
record_struct_name_prefix: str = 'Record'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Go needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble computed from date/datetime format.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

Under the RECORD strategy a list whose elements are record-shaped dicts is rendered as []any{ RecordN{...}, ... } (the elements format as struct literals, not as the map[string]... the typed opener would otherwise infer).

set_format: SetFormats = <function set_format_factory.<locals>._build>
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ('import "math"',)
property statement_terminator: str

String appended to each call expression.

statement_terminator_style: StatementTerminatorStyles = ''
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ('package main',)
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = True
supports_default_dict_value_type = True
supports_default_ordered_map_value_type = True
supports_default_sequence_element_type = True
supports_default_set_element_type = True
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = True
supports_record_struct_name_prefix = True
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap Go declaration + assignment in func main().

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a Go declaration in func main().

class literalizer.languages.Groovy(*args: object, **kwargs: object)

Groovy language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Groovy call style options.

KEYWORD = KeywordCallStyle(separator=': ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for Groovy.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Groovy.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

DEF = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Groovy.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Groovy.

SET = <function set_format_factory.<locals>._build>
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Groovy.

V4 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = KeywordCallStyle(separator=': ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

default_set_element_type: str = 'Object'
dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.groovy'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return a new ClassName constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'groovy'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Groovy needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = <function set_format_factory.<locals>._build>
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = True
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = False
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Haskell(*args: object, **kwargs: object)

Haskell language specification.

The generated output uses custom constructors (HNull, HBool, HList, HMap, HSet) that are not built-in Haskell types. To compile the generated code, define a Val ADT and typeclass instances in the consuming module:

data Val
  = HNull
  | HBool Bool
  | HInt Integer
  | HFloat Double
  | HStr String
  | HList [Val]
  | HMap [(String, Val)]
  | HSet [Val]

instance Num Val where
    fromInteger = HInt
    negate (HInt n)   = HInt (negate n)
    negate (HFloat f) = HFloat (negate f)
    ...

instance Fractional Val where
    fromRational r = HFloat (realToFrac r)
    ...

The Num / Fractional instances let numeric literals resolve to HInt / HFloat.

With the default EXPLICIT string format, strings are wrapped explicitly (e.g. HStr "hi"). The DOUBLE format instead uses OverloadedStrings so bare "hi" literals resolve to HStr "hi" via an IsString instance.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.HASKELLfromGregorian call, e.g. fromGregorian 2024 1 15. Requires the time package.

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.HASKELLUTCTime constructor, e.g. UTCTime (fromGregorian 2024 1 15) (secondsToDiffTime 45000). Requires the time package.

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

  • type_name – Name of the generated custom type. Defaults to "Val".

  • constructor_prefix – Prefix for generated constructor names. Defaults to "H", producing constructors like HNull, HBool, HInt, etc.

  • numeric_style

    How numeric literals are represented.

    • numeric_styles.OVERLOADED — emit Num and Fractional typeclass instances so that bare literals like 42 and 3.14 resolve to the custom type.

    • numeric_styles.EXPLICIT — wrap every numeric literal with its constructor (HInt 42, HFloat (3.14)) and omit the typeclass instances.

  • json_type – When set to json_types.AESON_VALUE, render values through the aesonQQ quasi-quote bracket from Data.Aeson.QQ so the output produces a Data.Aeson.Value instead of Haskell’s narrow custom Val algebraic type. Dict keys must be strings so they remain valid JSON object keys.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Haskell call style options.

CURRIED = CommandCallStyle(arg_separator=' ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='{-', suffix=' -}')
DOUBLE_DASH = CommentConfig(prefix='--', suffix='')
class DateFormats(*values)

Date format options for Haskell.

HASKELL = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=('{-# LANGUAGE OverloadedStrings #-}',), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Haskell.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
HASKELL = DatetimeFormatConfig(formatter=<function _build_haskell_datetime_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=('{-# LANGUAGE OverloadedStrings #-}',), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

BINARY = <function format_integer_binary>
DECIMAL = <class 'str'>
HEX = <function format_integer_hex>
OCTAL = <function format_integer_octal>
class JsonTypes(*values)

JSON value type options for Haskell.

AESON_VALUE = 'Data.Aeson.Value'

Data.Aeson.Value — the dynamic JSON value type from the aeson package.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED emits Num and Fractional typeclass instances so that bare numeric literals (42, 3.14) resolve to the custom type via fromInteger / fromRational.

EXPLICIT wraps every numeric literal with its constructor (HInt 42, HFloat 3.14) and omits the typeclass instances.

EXPLICIT = 2
OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Haskell.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)
TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Haskell.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
EXPLICIT = 2
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Haskell.

GHC2021 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = CommandCallStyle(arg_separator=' ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='--', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines for Haskell data declarations.

Under json_type the body preamble is reduced to the Data.Aeson and Data.Aeson.QQ imports needed by the aesonQQ quasi-quote bracket, so the custom Val algebraic type and its Num / IsString instances are not emitted.

constructor_prefix: str = 'H'
property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _build_haskell_datetime_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.hs'
property false_literal: str

Literal representing False.

float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Callable that rewrites a formatted direct call argument.

Curried calls parenthesize each argument so that constructor applications (HInt 1) are not parsed as additional arguments to the outer call.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

static format_call_binding_file_pragmas() tuple[str, ...]

File-level pragma emitted alongside a wrap_in_file scaffold whose top level contains an inference-bound call result.

Without an explicit signature the binding trips -Wmissing-signatures under -Wall -Werror; the literalizer cannot synthesize a signature because the call’s return type is not known at render time.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Callable that returns preamble stub declarations.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Callable that returns Haskell stub declarations for a call.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call expression.

The literal-binding declaration is prepended with a name :: Type annotation derived from the bound value’s runtime tagged-enum type; a call expression has no such tag, so the annotation is omitted and Haskell infers the call’s return type instead.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = True
integer_format: IntegerFormats = <class 'str'>
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

module_name: str = 'Check'
module_name_case: ClassVar[IdentifierCase] = 'pascal'
property null_literal: str

Literal representing None.

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'haskell'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Haskell needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble for Haskell imports.

Under json_type every temporal value is folded into the JSON text as an ISO-8601 string and every string ships inside that same JSON literal, so the per-scalar Haskell extension directives and imports that the configured date_format / datetime_format would otherwise add do not apply.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
property static_preamble: Sequence[str]

Static preamble lines emitted once per file.

When json_type is active the QuasiQuotes pragma is emitted here so the aesonQQ quasi-quote bracket from Data.Aeson.QQ can parse the inline JSON document into a Data.Aeson.Value at compile time.

string_format: StringFormats = 2
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = False
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = False
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

property true_literal: str

Literal representing True.

property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

type_name: str = 'Val'
property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Wrap a sequence of top-level declarations alongside a block of bare call expressions.

Top-level name :: Type / name = value bindings stay at module scope and only the calls go inside main = do. The integration harness pairs each $ref declaration’s bare_code with a downstream call and uses this hook to avoid concatenating both halves into one content string, which would otherwise force the bindings into a do-block where they would need let injection.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a Haskell variable binding in a module.

class literalizer.languages.Haxe(*args: object, **kwargs: object)

Haxe language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

    • datetime_formats.EPOCH — Unix timestamp integer.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Haxe call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date formatting options for Haxe.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime formatting options for Haxe.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

FINAL = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = <class 'str'>
HEX = <function format_integer_hex>
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Haxe.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='] : Array<Dynamic>)', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Haxe.

Haxe has no native set literal, so a set is rendered as a type-annotated Array literal.

SET = <function set_format_factory.<locals>._build>
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

Only double-quoted strings are emitted: Haxe performs string interpolation in single-quoted strings, so double quotes give a literal $ with no escaping.

DOUBLE = <function _build_backslash_formatter.<locals>._format>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

ALWAYS = 2
NEVER = 1
SAFE = 3
formatter(*, auto_formatter: Callable[[str, str, Value, frozenset[Enum]], str], keyword: str) Callable[[str, str, Value, frozenset[Enum]], str]

Return the variable declaration formatter.

Collection literals already carry an explicit type cast, so NEVER and SAFE need no annotation; ALWAYS adds a redundant-but-valid annotation.

class VersionFormats(*values)

Version options for Haxe.

V4 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

default_dict_key_type: str = 'String'
default_dict_value_type: str = 'Dynamic'
default_set_element_type: str = 'Dynamic'
dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.hx'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return a new ClassName constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Format one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = <class 'str'>
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

module_name: str = 'Main'
module_name_case: ClassVar[IdentifierCase] = 'pascal'
null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'haxe'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({'abstract', 'break', 'case', 'cast', 'catch', 'class', 'continue', 'default', 'do', 'dynamic', 'else', 'enum', 'extends', 'extern', 'false', 'final', 'for', 'function', 'if', 'implements', 'import', 'in', 'inline', 'interface', 'macro', 'new', 'null', 'operator', 'overload', 'override', 'package', 'private', 'public', 'return', 'static', 'switch', 'this', 'throw', 'true', 'try', 'typedef', 'untyped', 'using', 'var', 'while'})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Haxe needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Haxe needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='] : Array<Dynamic>)', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = <function set_format_factory.<locals>._build>
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid Haxe file.

Everything (reference declarations, call stubs and the value itself) goes inside static function main() of a single class. Haxe permits local functions and anonymous-structure closures inside a function body, so call stubs are emitted as local declarations rather than file-scope types.

class literalizer.languages.Hcl(*args: object, **kwargs: object)

HCL (HashiCorp Configuration Language) language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Hcl call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for Hcl.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Hcl.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for HCL.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for HCL.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for HCL.

V2 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.hcl'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE,)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'hcl'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (HCL needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (HCL needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = False
supports_dotted_calls = False
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid HCL file.

When variable_name is empty (call rendering), bare function calls are not valid HCL, so each is assigned to a unique local _N. Top-level name = value statements (including multi-line list/object literals) are already valid HCL and pass through unchanged so a mixed file of variable declarations and calls parses correctly.

class literalizer.languages.Java(*args: object, **kwargs: object)

Java language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.JAVALocalDate.of(...) call, e.g. LocalDate.of(2024, 1, 15).

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.INSTANTInstant.parse(...) call, e.g. Instant.parse("2024-01-15T12:30:00").

    • datetime_formats.ZONEDZonedDateTime.of(...) call, e.g. ZonedDateTime.of(2024, 1, 15, 12, 30, 0, 0, ZoneId.of("UTC")).

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

  • sequence_format

    How to format sequences.

    • sequence_formats.ARRAY — Java array literal, e.g. new Object[]{1, 2, 3}.

    • sequence_formats.LISTList.of(...) call, e.g. List.of(1, 2, 3).

  • json_type – When set to json_types.JACKSON_JSON_NODE, render values through Jackson’s ObjectMapper.readTree(...) so the output produces a com.fasterxml.jackson.databind.JsonNode instead of Java’s narrow List / Map / array types.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Java call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date formatting options for Java.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
JAVA = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDate;',), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime formatting options for Java.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
INSTANT = DatetimeFormatConfig(formatter=<function _format_datetime_java_instant>, preamble_lines=('import java.time.Instant;',), type_produced=<class 'datetime.datetime'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
ZONED = DatetimeFormatConfig(formatter=<function _format_datetime_java_zoned>, preamble_lines=('import java.time.ZoneId;', 'import java.time.ZonedDateTime;'), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

VAR = DeclarationStyleConfig(formatter=<function _format_java_var_declaration>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

HASH_MAP = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close='))', format_entry=<function dict_entry_with_template.<locals>._format>, empty_dict='new HashMap<>()', preamble_lines=('import java.util.HashMap;', 'import java.util.Map;'), narrowed_open=None, supports_trailing_comma=False)
MAP_OF_ENTRIES = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close=')', format_entry=<function dict_entry_with_template.<locals>._format>, empty_dict=None, preamble_lines=('import java.util.Map;',), narrowed_open=None, supports_trailing_comma=False)
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Strategy for dicts whose values span more than one Java type.

ERROR keeps Java’s strict-typing behavior (mixed-value dicts that cannot be represented raise). RECORD renders each record-shaped dict (non-empty, string-keyed) as a generated record declared in the preamble plus a matching positional new Record0(...) literal, so fields may legitimately mix scalars and containers.

ERROR = 1
RECORD = 2
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal_c_style>, 'UNDERSCORE': <function format_integer_octal_c_style>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(*values)

JSON value type options for Java.

JACKSON_JSON_NODE = 'com.fasterxml.jackson.databind.JsonNode'

Jackson’s dynamic JSON value type.

Modifiers

alias of _JavaModifiers

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

AUTO = 2
NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Java.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback='new Object[]{', uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
LIST = SequenceFormatConfig(sequence_open=<function _list_of_open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='List.of()', preamble_lines=('import java.util.List;',), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Java.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=('import java.util.Set;',), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=False)
TREE_SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='))', empty_set='new TreeSet<>()', preamble_lines=('import java.util.Set;', 'import java.util.TreeSet;'), set_opener_template='', supports_heterogeneity=False, supports_trailing_comma=False)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

ALWAYS = 2
NEVER = 1
SAFE = 3
formatter(*, auto_formatter: Callable[[str, str, Value, frozenset[Enum]], str], int_type: str, date_hint: str, datetime_hint: str, seq_is_array: bool, dict_outer: str, set_outer: str) Callable[[str, str, Value, frozenset[Enum]], str]

Return the variable declaration formatter.

class VersionFormats(*values)

Version options for Java.

  • VersionFormats.JDK_11: target Java 11.

  • VersionFormats.JDK_16: target Java 16.

The RECORD heterogeneous_strategy emits record declarations, which require Java 16 or newer, so a RECORD spec pins language_version to JDK_16.

JDK_11 = 1
JDK_16 = 2
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

Always emits import java.math.BigInteger; when the data needs it; under HeterogeneousStrategies.RECORD also emits one record declaration per record shape present in the data. When json_type is active, neither the BigInteger import nor record declarations apply: integers outside the 64-bit range ride inside the JSON text, and the data flows through a single ObjectMapper.readTree call instead of typed records.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDate;',), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_java_instant>, preamble_lines=('import java.time.Instant;',), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_java_var_declaration>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close=')', format_entry=<function dict_entry_with_template.<locals>._format>, empty_dict=None, preamble_lines=('import java.util.Map;',), narrowed_open=None, supports_trailing_comma=False)
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.java'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return a new ClassName constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

EPOCH seconds are routed through format_integer so a post-2038 value carries the L suffix Java requires for an integer literal outside 32-bit range: a bare 4085195400 fails to compile as an int literal even when assigned to a long. In-range epoch seconds format identically to the plain integer, so every checked-in golden file stays byte-identical.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: Callable[[int], str]

Always-L-suffixed integer formatter for widened collections (mixed-magnitude int sets/lists).

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the behavior for the chosen heterogeneous strategy.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = 1
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = (ModifierCombination(name='public_static_final', modifiers=frozenset({<_JavaModifiers.PUBLIC: 'public'>, <_JavaModifiers.FINAL: 'final'>, <_JavaModifiers.STATIC: 'static'>})),)
modifiers

alias of _JavaModifiers

module_name: str = 'Module'
module_name_case: ClassVar[IdentifierCase] = 'pascal'
null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'java'
record_shape_names: Mapping[frozenset[str], str]
record_struct_name_prefix: str = 'Record'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Java needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble computed from date/datetime format.

Under json_type every temporal value is folded into the JSON text as an ISO-8601 string, so the temporal Java imports that the configured date_format / datetime_format would otherwise add do not apply.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback='new Object[]{', uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=('import java.util.Set;',), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=False)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = True
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
property static_preamble: Sequence[str]

Static preamble lines emitted once per file.

When json_type is active the Jackson JsonNode and ObjectMapper imports are emitted here so every fixture has them in scope regardless of the rendered data.

string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = True
supports_record_shape_names = True
supports_record_struct_name_prefix = True
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Raise if the spec cannot produce valid code for data.

Under the RECORD heterogeneous strategy a list-valued record component is typed from the array opener (new <type>[]{) the value formatter emits, so its declared type matches the rendered literal. Only sequence_format=ARRAY produces that opener; every other sequence format (e.g. LIST -> List.of(...)) carries no element type in its opener and is outside the RECORD strategy’s MVP (cf. the set / non-record-dict boundary in #2317), so the combination is rejected here rather than emitting a record declaration that fails to compile. This check is spec-only; data is unused.

When json_type is active, additionally walk data to reject non-string dict keys, which JSON objects cannot represent.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap Java declaration + assignment in a static method.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a Java declaration in a class scope named after the configured module name.

When content starts with a class-field modifier keyword (public, private, protected, static) the declaration is placed at class-field scope, which is the only context where those modifiers are valid. Otherwise the declaration goes inside a public static void method named after the configured module name so that local-only forms like var x = 42; compile.

class literalizer.languages.JavaScript(*args: object, **kwargs: object)

JavaScript language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.JSnew Date(...) call, e.g. new Date("2024-01-15").

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.JSnew Date(...) call, e.g. new Date("2024-01-15T12:30:00").

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

JavaScript call style options.

OBJECT = ObjectCallStyle(separator=': ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date formatting options for JavaScript.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
JS = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime formatting options for JavaScript.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
JS = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

CONST = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

MAP = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close='])', format_entry=<function dict_entry_with_template.<locals>._format>, empty_dict='new Map()', preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)
OBJECT = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close='}', format_entry=<function dict_entry_with_separator.<locals>._format>, empty_dict=None, preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for JavaScript.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for JavaScript.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='new Set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

NONE = 'none'
SEMICOLON = 1
wrap_formatter(formatter: Callable[[str, str, Value, frozenset[Enum]], str]) Callable[[str, str, Value, frozenset[Enum]], str]

Wrap a formatter to match this statement terminator style.

class StringFormats(*values)

String format options.

DOUBLE = <function _build_backslash_formatter.<locals>._format>
SINGLE = <function _build_backslash_formatter.<locals>._format>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for JavaScript.

ES2015 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = ObjectCallStyle(separator=': ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close='}', format_entry=<function dict_entry_with_separator.<locals>._format>, empty_dict=None, preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.js'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return a new ClassName constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)
indent: str = '  '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'javascript'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (JavaScript needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (JavaScript needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='new Set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Json5(*args: object, **kwargs: object)

JSON5 language specification.

Produces JSON5 values — objects for mappings, and arrays for sequences and sets — following the JSON5 Data Interchange Format.

JSON5 is a superset of JSON that permits unquoted identifier keys, trailing commas, single- and double-quoted strings, comments, and several other syntactic relaxations.

Dates and datetimes are rendered as quoted ISO 8601 strings because JSON5 has no native date type.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Json5 call style options.

class CommentFormats(*values)

Comment style options.

DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for Json5.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Json5.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for JSON5.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for JSON5.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for JSON5.

V1 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style_config: ClassVar[PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle | CallSupport] = 'not_in_language'
call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.json5'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Raise for any {"$ref": "name"} identifier.

JSON5 is a data format; values must be literals, not variable references, so refs are not supported.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'json5'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (JSON5 needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (JSON5 needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = False
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = False
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Jsonnet(*args: object, **kwargs: object)

Jsonnet language specification.

Produces Jsonnet values — objects for mappings, and arrays for sequences and sets — following the Jsonnet data templating language.

Jsonnet is a superset of JSON that permits unquoted identifier keys, trailing commas, single- and double-quoted strings, comments, and powerful data templating features.

Dates and datetimes are rendered as quoted ISO 8601 strings because Jsonnet has no native date type.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Jsonnet call style options.

KEYWORD = KeywordCallStyle(separator='=')
class CommentFormats(*values)

Comment style options.

DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for Jsonnet.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Jsonnet.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Jsonnet.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Jsonnet.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Jsonnet.

V0_20 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = KeywordCallStyle(separator='=')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.jsonnet'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Raise for any {"$ref": "name"} identifier.

Jsonnet output snippets do not include a local preamble, so variable references cannot be resolved.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'jsonnet'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Jsonnet needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Jsonnet needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = False
supports_variable_names = False
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid Jsonnet file.

When variable_name is empty (call mode), wrap the content lines in an array so the file evaluates to a single expression.

class literalizer.languages.Julia(*args: object, **kwargs: object)

Julia language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.JULIADate(...) constructor call, e.g. Date(2024, 1, 15).

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.JULIADateTime(...) constructor call, e.g. DateTime(2024, 1, 15, 12, 30, 0).

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

  • sequence_format

    Which Julia sequence type to use.

    • sequence_formats.ARRAY — array literal, e.g. [1, 2, 3].

    • sequence_formats.TUPLE — tuple literal, e.g. (1, 2, 3).

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Julia call style options.

KEYWORD = KeywordCallStyle(separator='=')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='#=', suffix=' =#')
HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date formatting options for Julia.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
JULIA = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('using Dates',), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime formatting options for Julia.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
JULIA = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=('using Dates',), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DICT = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close=')', format_entry=<function dict_entry_with_separator.<locals>._format>, empty_dict='Dict()', preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)
ORDERED = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close=')', format_entry=<function dict_entry_with_separator.<locals>._format>, empty_dict='OrderedDict()', preamble_lines=('using DataStructures',), narrowed_open=None, supports_trailing_comma=True)
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Julia.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=True, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Julia.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='Set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Julia.

V1_9 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = KeywordCallStyle(separator='=')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('using Dates',), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=('using Dates',), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close=')', format_entry=<function dict_entry_with_separator.<locals>._format>, empty_dict='Dict()', preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.jl'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Raise for any {"$ref": "name"} identifier.

Julia output is not wrapped in a function body, so variable references require a surrounding assignment that cannot be injected.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'nothing'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'julia'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Julia needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble computed from date/datetime format.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='Set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Kotlin(*args: object, **kwargs: object)

Kotlin language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.KOTLINLocalDate.of(...) call, e.g. LocalDate.of(2024, 1, 15).

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.KOTLINLocalDateTime.of(...) call, e.g. LocalDateTime.of(2024, 1, 15, 12, 30, 0).

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

  • sequence_format

    Which Kotlin sequence type to use.

    • sequence_formats.LIST — typed array calls (e.g. intArrayOf(1, 2, 3)). Heterogeneous sequences fall back to listOf<Any?>(…).

    • sequence_formats.TUPLEPair(…) for two-element sequences, Triple(…) for three-element sequences, e.g. Pair("a", 1). Other sizes fall back to listOf<Any?>(…).

  • json_type – When set to json_types.KOTLINX_JSON_ELEMENT, render values through Json.parseToJsonElement(...) so the output produces a kotlinx.serialization.json.JsonElement instead of Kotlin’s narrow List / Map / array types.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Kotlin call style options.

KEYWORD = KeywordCallStyle(separator=' = ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for Kotlin.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
KOTLIN = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDate',), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for Kotlin.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
KOTLIN = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDateTime',), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

VAL = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

HASH_MAP = _KotlinDictSpec(opener_template='hashMapOf<{key_type}, {type_name}>(')
MAP = _KotlinDictSpec(opener_template='mapOf<{key_type}, {type_name}>(')
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Strategy for dicts whose values span more than one Kotlin type.

ERROR keeps Kotlin’s strict-typing behavior (mixed-value dicts that cannot be represented raise). RECORD renders each record-shaped dict (non-empty, string-keyed) as a generated data class declared in the preamble plus a matching constructor-call literal, so fields may legitimately mix scalars and containers. TUPLE composes RECORD and additionally renders a fixed-length heterogeneous scalar array that is a dict value or the document root as a two-element Pair(...) or three-element Triple(...) typed Pair<...> / Triple<...> – a record field whose value is such an array becomes a tuple-typed field. Kotlin has no general N-tuple, so an array of any other length raises TupleArityNotRepresentableError rather than degrading to a homogeneous list.

ERROR = 1
RECORD = 2
TUPLE = 3
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(*values)

JSON value type options for Kotlin.

KOTLINX_JSON_ELEMENT = 'kotlinx.serialization.json.JsonElement'

Dynamic JSON value type from kotlinx.serialization.json.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Kotlin.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
LIST = SequenceFormatConfig(sequence_open=<function typed_collection_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback='listOf<Any?>(', uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
TUPLE = SequenceFormatConfig(sequence_open=<function _kotlin_tuple_open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Kotlin.

SET = <function set_format_factory.<locals>._build>
SORTED_SET = <function set_format_factory.<locals>._build>
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

ALWAYS = 2
NEVER = 1
SAFE = 3
formatter(*, auto_formatter: Callable[[str, str, Value, frozenset[Enum]], str], keyword: str, date_hint: str, datetime_hint: str, default_set_element_type: str, default_dict_key_type: str, default_dict_value_type: str, dict_outer: str, set_outer: str, sequence_format_name: str) Callable[[str, str, Value, frozenset[Enum]], str]

Return the variable declaration formatter.

class VersionFormats(*values)

Version options for Kotlin.

V1_9 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = KeywordCallStyle(separator=' = ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

Always emits import java.math.BigInteger when the data carries an out-of-range integer; under HeterogeneousStrategies.RECORD additionally emits one data class declaration per record shape present in the data. When json_type is active neither applies: integers outside the 64-bit range ride inside the JSON text, and the data flows through a single Json.parseToJsonElement call instead of typed records.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDate',), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDateTime',), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

default_dict_key_type: str = 'String'
default_dict_value_type: str = 'Any?'
default_set_element_type: str = 'Any?'
dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = _KotlinDictSpec(opener_template='mapOf<{key_type}, {type_name}>(')
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.kts'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: Callable[[int], str]

Always-L-suffixed integer formatter for widened collections (mixed-magnitude int sets/lists).

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the behavior for the chosen heterogeneous strategy.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = 1
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'kotlin'
record_shape_names: Mapping[frozenset[str], str]
record_struct_name_prefix: str = 'Record'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Kotlin needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble computed from date/datetime format.

Under json_type every temporal value is folded into the JSON text as an ISO-8601 string, so the temporal Kotlin imports that the configured date_format / datetime_format would otherwise add do not apply.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function typed_collection_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback='listOf<Any?>(', uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

Under any record-rendering strategy (RECORD, or TUPLE which composes it) a list whose elements are record-shaped dicts opens as listOf<Any?>( (the elements format as RecordN(...) literals, not the Map<...> the typed opener would otherwise infer).

set_format: SetFormats = <function set_format_factory.<locals>._build>
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
property static_preamble: Sequence[str]

Static preamble lines emitted once per file.

When json_type is active the Json and JsonElement imports are emitted here so every fixture has them in scope regardless of the rendered data.

string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = True
supports_default_dict_value_type = True
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = True
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = True
supports_record_struct_name_prefix = True
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Validate the spec against the data.

When json_type is active, walk data to reject non- string dict keys, which JSON objects cannot represent.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Lua(*args: object, **kwargs: object)

Lua language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Lua call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='--[[', suffix=' ]]')
DOUBLE_DASH = CommentConfig(prefix='--', suffix='')
class DateFormats(*values)

Date format options for Lua.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
LUA = DateFormatConfig(formatter=<function _format_date_lua>, preamble_lines=(), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for Lua.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
LUA = DatetimeFormatConfig(formatter=<function _format_datetime_lua>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

LOCAL = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = <class 'str'>
HEX = <function format_integer_hex>
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Lua.

TABLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Lua.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = <function _build_backslash_formatter.<locals>._format>
SINGLE = <function _build_backslash_formatter.<locals>._format>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Lua.

V5_4 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='--', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function _format_date_lua>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_lua>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.lua'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = <class 'str'>
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'nil'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'lua'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Lua needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Lua needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = True
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

static validate_spec_for_data(data: Value) None

Reject inputs containing an empty mapping on Lua.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Matlab(*args: object, **kwargs: object)

MATLAB language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Matlab call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='%{', suffix=' %}')
PERCENT = CommentConfig(prefix='%', suffix='')
class DateFormats(*values)

Date format options for Matlab.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
MATLAB = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for Matlab.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
MATLAB = DatetimeFormatConfig(formatter=<function _format_datetime_matlab>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

CONTAINERS_MAP = DictFormatConfig(dict_open=<function _containers_map_open>, close='})', format_entry=<function _format_containers_map_entry>, empty_dict='containers.Map()', preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)
STRUCT = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close=')', format_entry=<function _format_matlab_dict_entry>, empty_dict='struct()', preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for MATLAB.

CELL_ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='{}', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for MATLAB.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set='{}', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for MATLAB.

R2022A = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='%', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_matlab>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close=')', format_entry=<function _format_matlab_dict_entry>, empty_dict='struct()', preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.m'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = '[]'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'matlab'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (MATLAB needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (MATLAB needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='{}', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set='{}', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Mojo(*args: object, **kwargs: object)

Mojo language specification.

By default Mojo raises on heterogeneous input because its native collections require a single element type. Opt into HeterogeneousStrategies.VARIANT to wrap mixed scalars in a generated comptime Value = Variant[...] and render each scalar as Value(...) so heterogeneous dicts and lists become homogeneous in the Variant type.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Mojo call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for Mojo.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Mojo.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function _mojo_format_variable_declaration>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = <function dict_format_factory.<locals>._build>
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Strategy for representing dicts or lists whose scalar values span more than one Mojo type.

ERROR = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)

Raise HeterogeneousScalarCollectionError (or HeterogeneousSiblingListsError) when scalar values of mixed types appear in a container that cannot represent them. This is the default, matching the single-element-type convention of the Mojo List, Dict, and Set containers.

VARIANT = _HeterogeneousStrategyConfig(build_behavior=<function _build_variant_behavior>, build_preamble=<function _build_variant_preamble>)

Auto-generate a comptime binding in the preamble for the configured name to a Variant[...] over only the Mojo types actually present in heterogeneous positions, together with a from std.utils.variant import Variant import, and wrap each such scalar as {Name}(value) (with an explicit String(...) or Float64(...) cast when needed so the constructor resolves to the intended Variant alternative, and NoneType() for nulls).

The alias name is configurable via Mojo.heterogeneous_value_variant_name (default "Value").

class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Mojo.

LIST = <function _mojo_list_format>
class SetFormats(*values)

Set type options for Mojo.

SET = <function set_format_factory.<locals>._build>
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Mojo.

V24_5 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Return True for ref values whose Mojo type is register- trivial.

Mojo 0.26.1.0+ rejects ^ on Int, Bool, and Float64 values under --Werror because the transfer has no effect. The trivial-register set is derived from _mojo_variant_for_scalar() so the formatter layer avoids hard-coded Mojo type-name strings.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

For HeterogeneousStrategies.VARIANT emits an alias line declaring the Variant over only the Mojo types actually used in heterogeneous positions. Other strategies produce no preamble.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _mojo_format_variable_declaration>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

default_dict_key_type: str = 'String'
default_dict_value_type: str = 'String'
default_sequence_element_type: str = 'String'
default_set_element_type: str = 'String'
dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = <function dict_format_factory.<locals>._build>
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = False
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.mojo'
false_literal: ClassVar[str] = 'False'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Emit a call-argument $ref as the bare identifier.

The Mojo transfer operator ^ consumes the variable, which is unsafe when the caller may use it again in a later call (or after the literalize_call block). Callers opt in to transferring a specific ref by listing it in literalize_call’s consumable_refs set; in that case format_call_arg_ref_identifier_consumable is used instead and appends ^.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Append ^ to a consumable call-argument $ref.

Used only for refs the caller declared as consumable on literalize_call() and that appear in just one call argument, so the transfer cannot strand a later use. Refs whose underlying value is a register-trivial scalar (Int, Bool, Float64) are routed away from this formatter at the call site (see consumable_ref_value_inhibits_consuming_form), because applying ^ to such a value is a hard error under --Werror.

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Append ^ to trigger move/transfer semantics in Mojo, except for register-trivial scalars.

Mojo Dict does not implement Copyable, so a bare variable reference fails to compile and ^ transfers ownership instead. Applying ^ to a register-trivial scalar (Int, Bool, Float64) is a hard error under --Werror, so we drop the operator when the caller’s ref_values identifies the ref as one of those types. When the value is unknown we keep the historical ^ form.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

Wraps the configured declaration formatter so a non-empty list of string-rendering elements gets an explicit List[String] annotation. Mojo infers List[StringLiteral] from a bare ["a", "b"] literal, which is rejected when assigned into a Variant slot expecting List[String].

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the behavior for the chosen heterogeneous strategy.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)
heterogeneous_value_variant_name: str = 'Value'
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'None'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'mojo'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Mojo needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Mojo needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = <function _mojo_list_format>
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = <function set_format_factory.<locals>._build>
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

property skip_null_dict_values: bool

Drop None dict values for the default ERROR strategy so the homogeneous-dict rendering stays valid Mojo.

VARIANT wraps every scalar as Value(...), so None values must flow through unchanged to be wrapped as Value(None) against a NoneType Variant alternative.

special_float_preamble: ClassVar[tuple[str, ...]] = ('import std.math',)
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = True
supports_default_dict_value_type = True
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = True
supports_default_set_element_type = True
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'True'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap Mojo declaration and assignment in a main function.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a Mojo variable declaration in a main function.

class literalizer.languages.Nim(*args: object, **kwargs: object)

Nim language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.NIM — table literal, e.g. {"year": 2024, "month": 1, "day": 15}.

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.NIM — table literal, e.g. {"year": 2024, "month": 1, "day": 15, "hour": 12, "minute": 30, "second": 0}.

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Nim call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='#[', suffix=' ]#')
HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for Nim.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
NIM = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for Nim.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
NIM = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

CONST = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Strategy for representing dicts or lists whose scalar values span more than one Nim type.

ERROR = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)

Raise HeterogeneousScalarCollectionError (or HeterogeneousSiblingListsError) when scalar values of mixed types appear in a container that cannot represent them. This is the default, matching the strict-typing convention of Nim when tables and sequences are used without JSON wrapping.

OBJECT_VARIANT = _HeterogeneousStrategyConfig(build_behavior=<function _build_object_variant_behavior>, build_preamble=<function _build_object_variant_preamble>)

Auto-generate a Nim object variant in the preamble containing only the branches actually present in the data, and wrap each heterogeneous scalar value as {VariantName}(kind: vkX, xVal: value).

Switches the dict rendering from %* {key: value} (which relies on the json module) to {key: value}.toTable so that the object-variant values can be stored directly. Nested sequences emit @[...] at every level, and the json import is dropped unless a date or datetime format still produces a JsonNode payload.

The variant-type name is configurable via Nim.heterogeneous_value_variant_name (default "Value"). Incompatible with DeclarationStyles.CONST: .toTable and @[] are runtime constructors, so CONST requires a compile-time-expressible initializer.

RECORD = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)

Render each record-shaped dict (non-empty, string-keyed) as a generated module-scope type Record0 = object declaration plus a matching Record0(field: value, ...) literal, so a dict mixing scalars with a container is representable even though a Nim Table requires a homogeneous value type.

Like OBJECT_VARIANT this switches collections to their native Nim constructors (@[...], {...}.toTable) so a seq/Table field is well-typed, but it wraps no scalars and emits no json/%* rendering. Auto names Record0, Record1, … (prefix configurable via Nim.record_struct_name_prefix); no record_shape_names, no record_unify_optional_fields, consistent with the other non-Rust ports. Its behavior and struct preamble need the per-instance renderer, so they are resolved in heterogeneous_behavior / data_dependent_preamble rather than from the enum member’s config builders (it reuses the no-op ERROR builders, kept a distinct member by _HeterogeneousStrategyConfig’s identity equality). Incompatible with DeclarationStyles.CONST for the same reason as OBJECT_VARIANT: @[...] / .toTable are runtime constructors.

class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(*values)

JSON value type options for Nim.

JSON_NODE = 'JsonNode'

Standard-library json.JsonNode value constructed via the %* macro.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Nim.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
SEQ = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=False, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=True, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Nim.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Nim.

V2 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for a call context.

For HeterogeneousStrategies.RECORD emits the type Record0 = object blocks a record-shaped call argument’s literal references, preceded – exactly as the non-call data_dependent_preamble – by the UnusedImport opt-out and import tables (dict_format_config no longer contributes it under RECORD). The opt-out is needed both for a record-only call (the import is then unused) and because a varargs[untyped] stub never evaluates its arguments, so even a non-record dict argument’s {...}.toTable would leave the import unused. For HeterogeneousStrategies.OBJECT_VARIANT emits the Nim type block declaring the object variant used to wrap heterogeneous scalars; the call rendering references that type by name, so the declaration must be present. For other strategies, call arguments are inline literals that never use %*, so import json is never needed in a call context.

json_type wraps every call argument in %*, so the import json line is contributed unconditionally here too.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

For HeterogeneousStrategies.RECORD emits one type Record0 = object block per distinct record shape in the data, preceded by import tables and the UnusedImport opt-out: a non-record dict (the empty dict, or an ordered map) renders as a runtime Table that needs the import, while a pure-record fixture leaves it unused, so the pragma keeps the always-present import warning-free rather than making the import data-dependent. For HeterogeneousStrategies.OBJECT_VARIANT emits a Nim type block declaring the object variant used to wrap heterogeneous scalars. For HeterogeneousStrategies.ERROR emits ("import json",) when the rendered output will use the %* JSON-construction operator (every variable declaration / assignment except const declarations and @-prefixed sequences of simple scalars); importing json unconditionally would trigger the Nim compiler’s UnusedImport warning. Under json_type the rendered output always uses %* (and newJ* builders), so the import is emitted unconditionally and takes precedence over any configured heterogeneous strategy.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

OBJECT_VARIANT and RECORD append .toTable to the closing brace so every rendered (non-record) dict becomes a runtime tables.Table. An empty dict widens to initTable[string, string]() so the compiler does not reject {}.toTable: an empty {} literal is an empty set rather than a table, so the call does not resolve and the key/value types cannot be inferred. This mirrors the newSeq[string]() widening for empty sequences.

OBJECT_VARIANT always wraps its dicts as tables, so it carries the import tables preamble here. Under RECORD a record-shaped dict never reaches this config (it is intercepted by the record renderer and emitted as a Record0(...) literal), so import tables would be an UnusedImport for the common record-only fixture; the import is instead added by data_dependent_preamble only when the data still carries a genuinely non-record dict that renders as a table.

json_type takes precedence: every dict literal is wrapped in %*({...}) so it renders as a JSON object, and an empty dict widens to newJObject() (the explicit builder). The import json line that powers %* is contributed by data_dependent_preamble, not by this config, so a heterogeneous-strategy-free fixture still imports it exactly once.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = False
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.nim'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Callable that rewrites a formatted direct call argument.

Under json_type every call argument is wrapped in %* so the underlying proc receives a JsonNode; under any other mode call arguments pass through unchanged.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment binding a call result.

The call-expression counterpart of format_variable_assignment; the %*/@ wrapping is dropped since a call result is bound directly. Unlike the declaration form this carries no var/let/const keyword, so it does not reuse the declaration-style formatter.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call result.

The literal-binding declaration prefixes the right-hand side with the %* json macro (or @ for sequences) chosen from the parsed literal’s type; that JSON-constructs a literal and is invalid for a call result. The plain <keyword> <name> = <value> declaration-style formatter binds the call result directly with no wrapping.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

json_type overrides the configured date_format with the ISO 8601 string form because the NIM table-literal form would not round-trip through JSON.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

json_type overrides the configured datetime_format with the ISO 8601 string form unless the user has explicitly chosen the EPOCH integer form, which remains a valid JSON number.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

Under json_type the assigned expression is wrapped by %* through the same helper as the declaration form so the two halves of a combined declaration / assignment stay consistent.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

Under json_type the declaration carries an explicit : JsonNode type annotation and the right-hand side is wrapped by %* only when the value is not already a JsonNode expression (the wrapping check in _nim_json_value_expression() skips re-wrapping %*(...) and newJ* builders so the rendered output stays flat).

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the behavior for the chosen heterogeneous strategy.

json_type relaxes scalar-type checks unconditionally, because the %* macro accepts heterogeneous JSON values. RECORD resolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member); ERROR and OBJECT_VARIANT use their config-built behaviors.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)
heterogeneous_value_variant_name: str = 'Value'
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'nil'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

OBJECT_VARIANT and RECORD render an ordered map with its native {...}.toOrderedTable constructor (an ordered map is never record-shaped, so RECORD leaves it on this path). json_type renders an ordered map as a JSON object (the %* macro preserves object-key insertion order in the rendered output).

pygments_name = 'nim'
record_struct_name_prefix: str = 'Record'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Nim needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble for Nim scalar types.

Under the default ERROR heterogeneous strategy import json is added by data_dependent_preamble only when the rendered output uses %*. Under OBJECT_VARIANT scalars are emitted as native Nim values, except that the NIM date / datetime formats still produce a json.JsonNode payload and require import json whenever a date or datetime is present. Under json_type the import json line is contributed unconditionally by data_dependent_preamble, so this method returns an empty per-scalar map to avoid duplicating it.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=False, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=True, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

json_type wraps every sequence literal in the %* macro so it renders as a JsonNode array, and widens an empty sequence to newJArray() (the explicit JSON array builder). OBJECT_VARIANT and RECORD replace the JSON-array opener with @[ so nested sequences render as Nim-native seq literals at every level (the declaration formatter no longer adds a leading @ because uses_typed_literal_for_scalars is turned off). Empty sequences widen to newSeq[string]() so the compiler does not reject var x = @[] with “cannot infer the type of the sequence” – and, under RECORD, so the widened element type matches the seq[string] an empty-list record field is declared.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

json_type renders a set as a JSON array via %*([...]) because JSON has no native set type; empty sets widen to newJArray() for the same reason empty sequences do.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = True
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Nix(*args: object, **kwargs: object)

Nix language specification.

Produces Nix values — attribute sets for mappings, and lists for sequences and sets — following Nix syntax.

Nix is a purely functional, lazy language used primarily for the Nix package manager. It supports attribute sets ({ key = value; }), lists ([ elem1 elem2 ]), strings, integers, floats, booleans, and null.

Lists are space-separated with no commas. Attribute set entries end with semicolons.

Dates and datetimes are rendered as quoted ISO 8601 strings because Nix has no native date type.

Dict keys that cannot be represented as Nix attribute names raise InvalidDictKeyError.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Nix call style options.

class CommentFormats(*values)

Comment style options.

HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for Nix.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Nix.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ERROR = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Nix.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Nix.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Nix.

V2 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style_config: ClassVar[PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle | CallSupport] = 'not_implemented_by_tool'
call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ' '
empty_dict_keys

alias of EmptyDictKey

extension = '.nix'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL)
indent: str = '  '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'nix'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Nix needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Nix needs none).

static sequence_binding_declarations(declarations: tuple[str, ...]) str

Chain Nix bindings as nested let blocks.

Each Nix binding’s bare_code has the shape let NAME = VALUE; in NAME (the language’s declaration template). Concatenating these verbatim is invalid Nix, so every binding except the last has its trailing in NAME result expression dropped, leaving let NAME = VALUE; in; the bindings are then chained so each subsequent binding is the body of the previous let. The final binding keeps its full ; in NAME tail so the file evaluates to that value. The identifier is removed structurally using the known ; in <name> suffix shape, not a regex over the rendered value.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.KEBAB, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = False
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Norg(*args: object, **kwargs: object)

Norg markup language specification.

Produces data literals using Norg-compatible syntax — square brackets for sequences and sets, curly braces for mappings, and key: value for dict entries.

Norg comments use the null attached modifier: % comment %.

Variable declarations use a heading followed by a ranged verbatim tag: * name then @code json / @end.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Norg call style options.

class CommentFormats(*values)

Comment style options.

PERCENT = CommentConfig(prefix='%', suffix='%')
class DateFormats(*values)

Date format options for Norg.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Norg.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

BLOCK = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Norg.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Norg.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Norg.

V0_14 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style_config: ClassVar[PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle | CallSupport] = 'not_in_language'
call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='%', suffix='%')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.norg'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE,)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name: ClassVar[str | None] = None
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Norg needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Norg needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = False
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.OCaml(*args: object, **kwargs: object)

OCaml language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.OCAML — tuple literal, e.g. (2024, 1, 15).

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.OCAML — pair of tuples, e.g. ((2024, 1, 15), (12, 30, 0)).

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

  • type_name – Name of the generated custom type. Defaults to "val_t".

  • constructor_prefix – Prefix for generated constructor names. Defaults to "O", producing constructors like ONull, OBool, OInt, etc.

  • json_type

    Opt into rendering through a JSON value type instead of the generated tagged ADT.

    • None (default) — emit the custom val_t ADT.

    • json_types.YOJSON_SAFE_T — emit Yojson.Safe.t polymorphic-variant literals using the standard yojson tag set (Bool, Int, Float, String, Null, List, Assoc, Intlit). Dates, datetimes, times, and bytes reformat to JSON-friendly strings; arbitrary-precision integers route through the Intlit escape hatch; the type val_t preamble is dropped.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

OCaml call style options.

CURRIED = CommandCallStyle(arg_separator=' ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

PAREN_STAR = CommentConfig(prefix='(*', suffix=' *)')
class DateFormats(*values)

Date format options for OCaml.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
OCAML = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for OCaml.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
OCAML = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(*values)

JSON value type options for OCaml.

YOJSON_SAFE_T = 'Yojson.Safe.t'

Yojson.Safe.t — the polymorphic-variant JSON value type from the yojson package.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for OCaml.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='|]', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='val_t array', narrowed_empty_form=None)
LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='val_t', narrowed_empty_form=None)
class SetFormats(*values)

Set type options for OCaml.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for OCaml.

V5 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='(*', suffix=' *)')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

constructor_prefix: str = 'O'
property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = '; '
empty_dict_keys

alias of EmptyDictKey

extension = '.ml'
property false_literal: str

False literal using the configured constructor prefix.

float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Callable that rewrites a formatted direct call argument.

Curried calls parenthesize each argument so that constructor applications are not parsed as additional arguments to the outer call.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Wrap a call expression as a let binding.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an existing-variable binding of a call expression.

OCaml has no mutable reassignment, so an ExistingVariable binding is just another let. Like format_call_variable_declaration, the : val_t annotation and tag constructor are omitted so OCaml infers the call’s return type instead of the literal-binding formatter producing let x : val_t = OInt make_widget(42).

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call expression.

The literal-binding declaration annotates the binding with the custom type and wraps the value in a tag constructor derived from its runtime type (let x : val_t = OInt 42); a call expression has no such tag, so both the annotation and the tag are omitted and OCaml infers the call’s return type instead (let x = make_widget(42)).

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Callable that formats a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Callable that formats a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

property null_literal: str

Null literal using the configured constructor prefix.

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'ocaml'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble for OCaml.

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (OCaml needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='val_t', narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = False
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

property true_literal: str

True literal using the configured constructor prefix.

property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

type_name: str = 'val_t'
property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap an OCaml let declaration in a module.

class literalizer.languages.ObjectiveC(*args: object, **kwargs: object)

Objective-C language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function _format_objc_bytes_base64>
HEX = <function _format_objc_bytes>
class CallStyles(*values)

ObjectiveC call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for ObjectiveC.

ISO = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
OBJC = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for ObjectiveC.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
OBJC = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

TYPED = DeclarationStyleConfig(formatter=<function _format_objc_declaration>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = <class 'str'>
HEX = <function format_integer_hex>
OCTAL = <function format_integer_octal_c_style>
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Objective-C.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='@[]', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Objective-C.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']]', empty_set='[NSSet set]', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Objective-C.

V2 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function _format_objc_bytes>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_objc_declaration>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.m'
false_literal: ClassVar[str] = '@NO'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Box each call argument as an id so call sites match the concrete prototype emitted by _objc_call_stub().

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target so the root matches the k-prefixed const global emitted by _objc_call_stub().

property format_call_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment binding a call expression.

The call-expression counterpart of format_variable_assignment; the @(...) boxing is dropped since a call already yields an object pointer.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call expression.

The literal-binding declaration boxes a primitive right-hand side as NSNumber / NSString (an id is a pointer type); a call expression already yields an object pointer, so the @(...) boxing is dropped and the call result is bound directly.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

Values above LLONG_MAX get a ULL suffix so clang does not reinterpret the literal as an unsigned type and emit the warning the lint workflow treats as an error; values below LLONG_MIN raise UnrepresentableIntegerError since no signed or unsigned 64-bit integer can hold them.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = <class 'str'>
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

module_name: str = 'Module'
module_name_case: ClassVar[IdentifierCase] = 'snake'
null_literal: ClassVar[str] = '[NSNull null]'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'objective-c'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Objective-C needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Objective-C needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='@[]', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']]', empty_set='[NSSet set]', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ('#import <Foundation/Foundation.h>',)
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = False
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = '@YES'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap Objective-C declaration + assignment in a function.

Reads variable_name between the declaration and the assignment so the initial value is not a dead store flagged by clang-tidy’s clang-analyzer-deadcode.DeadStores check.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap an Objective-C declaration in a main function.

class literalizer.languages.Occam(*args: object, **kwargs: object)

Occam-pi language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Occam call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

DOUBLE_DASH = CommentConfig(prefix='--', suffix='')
class DateFormats(*values)

Date format options for Occam.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Occam.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

VAL = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Occam.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Occam.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Occam.

V2 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='--', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.occ'
false_literal: ClassVar[str] = 'MOBILE LIT(lit.bool; FALSE)'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Wrap direct call arguments in MOBILE LIT constructors.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.UPPER_SNAKE, IdentifierCase.SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

module_name: str = 'Module'
module_name_case: ClassVar[IdentifierCase] = 'snake'
null_literal: ClassVar[str] = 'MOBILE LIT(lit.null)'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name: ClassVar[str | None] = None
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Occam needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Occam needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ('MOBILE DATA TYPE LIT IS\n  CASE\n    lit.null\n    lit.bool ; BOOL\n    lit.int ; INT\n    lit.float ; REAL32\n    lit.str ; MOBILE []BYTE\n    lit.list ; MOBILE []MOBILE LIT\n    lit.map ; MOBILE []MOBILE LIT\n    lit.pair ; MOBILE []BYTE ; MOBILE LIT\n    lit.set ; MOBILE []MOBILE LIT\n:',)
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'MOBILE LIT(lit.bool; TRUE)'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap an occam-pi VAL declaration in a PROC.

class literalizer.languages.Odin(*args: object, **kwargs: object)

Odin language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Odin call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for Odin.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Odin.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

SHORT = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options.

ERROR raises on a heterogeneous scalar collection. RECORD instead renders each record-shaped dict (non-empty, string-keyed) as a generated package-scope struct plus a matching Record0{ field = value, ... } literal, so a dict may mix scalars and containers that the homogeneous map[string]V cannot.

ERROR = 1
RECORD = 2
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(*values)

JSON value type options for Odin.

JSON_VALUE = 'json.Value'

Odin’s standard core:encoding/json Value sum type.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Odin.

DYNAMIC_ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Odin.

SET = <function set_format_factory.<locals>._build>
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Odin.

DEV_2024 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

Under json_type the data rides inside a single JSON string, so no per-data preamble applies. For HeterogeneousStrategies.RECORD emits one struct declaration per record shape present in the data; otherwise produces no preamble.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

default_set_element_type: str = 'string'
dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.odin'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Callable that rewrites a formatted direct call argument.

Under json_type each argument is a json.Value produced by _json_parse; otherwise the framework’s formatted text passes through unchanged.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment binding a call result.

The call-expression counterpart of format_call_variable_declaration; the json-mode _json_parse shortcut applied to literal assignments would substitute the argument data for the formatted call expression and is dropped here.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call result.

Always uses the plain {name} := {value} form regardless of json_type: a call’s return type is opaque to the renderer (the generated proc stub returns any), and the json-mode _json_parse shortcut applied to literal bindings would discard the formatted call expression and substitute the argument data, which is not the call’s return value.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

Under json_type set entries fold into the JSON text and the per-entry string is discarded, so the framework just needs a permissive identity arm rather than the "key" = {} map-as-set form.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

Under json_type the assignment uses the _json_parse call shortcut instead of the framework’s formatted value.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

Under json_type the declaration is a _json_parse call call (the inferred return type is json.Value), bypassing both the framework’s formatted value and the nil-safe : any = nil shim.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the behavior for the chosen heterogeneous strategy.

Under json_type heterogeneous scalars all flow through the JSON text, so scalar-uniformity checks are skipped.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = 1
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)
indent: str = '\t'
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'nil'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'odin'
record_struct_name_prefix: str = 'Record'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Odin needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Odin needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

Under json_type lists fold into the JSON text and the framework’s formatted output is discarded.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = <function set_format_factory.<locals>._build>
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ('import "core:math"',)
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
property static_preamble: Sequence[str]

File-scope preamble.

Under json_type the package gains a core:encoding/json import plus a tiny _json_parse helper so every literalized value can render as a single _json_parse call call.

string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = True
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = True
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

Under json_type direct call arguments flow through the same _json_parse shortcut as variable bindings, so they need the same dict-key / backtick rejection that validate_spec_for_data() applies on the variable path.

validate_spec_for_data(data: Value) None

Raise if the spec cannot produce valid code for data.

When json_type is active, walk data to reject non-string dict keys (which JSON objects cannot represent) and strings (string values or string-typed dict keys) carrying a literal backtick (which would terminate the Odin raw-string delimiter that wraps the embedded JSON text).

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap an Odin declaration in a main procedure.

Under json_type an ExistingVariable form produces a bare my_data = _json_parse(...) line, which the Odin compiler rejects (the name is undeclared); inject a zero-valued my_data: any declaration ahead of the assignment so the wrapped file still compiles. Typed any (not json.Value): the assignment may bind either a _json_parse value or a call result whose stub returns any, and only any accepts both.

class literalizer.languages.Perl(*args: object, **kwargs: object)

Perl language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.PERLDateTime->new(...) call, e.g. DateTime->new(year => 2024, month => 1, day => 15).

    • date_formats.ISO – ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.PERLDateTime->new(...) call, e.g. DateTime->new(year => 2024, month => 1, day => 15, hour => 12, minute => 30, second => 0, time_zone => 'UTC').

    • datetime_formats.ISO – ISO 8601 quoted string, e.g. "2024-01-15T12:30:00+00:00".

  • bool_format

    How to format bool values. Perl has no native boolean type, so the choice trades off readability against round-trip fidelity through JSON and YAML libraries.

    • bool_formats.INTEGER – bare 1 / 0 (default, preserves prior output). Re-encoding to JSON loses the boolean type.

    • bool_formats.JSON_PP_REF\1 / \0 scalar references, the conventional form used by JSON::PP, JSON::XS, Cpanel::JSON::XS and Mojo::JSON. Round-trips back to JSON true / false with no use preamble required.

    • bool_formats.JSON_PP_SINGLETONJSON::PP::true / JSON::PP::false blessed singletons; adds a use JSON::PP; preamble (JSON::PP is a core module).

    Only boolean values round-trip; Perl coerces every hash key to a string, so a boolean dict key cannot preserve any non-string representation regardless of bool_format.

  • string_format

    How to format str values.

    • string_formats.DOUBLE (default) – double-quoted with every non-ASCII character escaped as \x{HHHH}. The output is pure ASCII and round-trips regardless of the surrounding source-file encoding.

    • string_formats.DOUBLE_UTF8 – double-quoted with non-ASCII characters emitted literally; contributes use utf8; to the file preamble whenever the literalized value contains a non-ASCII string, so Perl decodes the source as UTF-8. Matches the style a human Perl author would write in a UTF-8 source file.

    • string_formats.SINGLE – single-quoted, with only \\ and \' recognized as escapes. Non-ASCII characters are emitted as their raw UTF-8 bytes; the caller is responsible for placing the snippet in a source file whose encoding declaration matches.

class BoolFormats(*values)

Boolean format options for Perl.

INTEGER = _BoolFormatConfig(true_literal='1', false_literal='0', preamble_lines=())
JSON_PP_REF = _BoolFormatConfig(true_literal='\\1', false_literal='\\0', preamble_lines=())
JSON_PP_SINGLETON = _BoolFormatConfig(true_literal='JSON::PP::true', false_literal='JSON::PP::false', preamble_lines=('use JSON::PP;',))
class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Perl call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for Perl.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
PERL = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('use DateTime;',), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for Perl.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
PERL = DatetimeFormatConfig(formatter=<function _format_datetime_perl>, preamble_lines=('use DateTime;',), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

MY = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal_c_style>, 'UNDERSCORE': <function format_integer_octal_c_style>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class IntegerWidthStrategies(*values)

Integer-width rendering strategies.

  • BARE (default) - emit every integer as a bare numeric literal. Values whose magnitude exceeds 2**53 silently lose precision on parse because Perl converts them to an NV float; this matches the historical behavior.

  • MATH_BIG_INT - wrap integers whose magnitude exceeds 2**53 as Math::BigInt->new("...") and emit a use Math::BigInt; preamble. Smaller integers stay as bare literals.

BARE = 1
MATH_BIG_INT = 2
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Perl.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Perl.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = <function _format_perl_string_double>
DOUBLE_UTF8 = <function _format_perl_string_double_utf8>
SINGLE = <function format_string_backslash_single_minimal>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Perl.

V5_36 = 1
allows_empty_call_parens = True
bool_format: BoolFormats = _BoolFormatConfig(true_literal='1', false_literal='0', preamble_lines=())
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

Composes the MATH_BIG_INT integer-width contribution with the DOUBLE_UTF8 string-format contribution so a value triggering both gets both preamble lines in a stable order.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('use DateTime;',), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_perl>, preamble_lines=('use DateTime;',), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.pl'
property false_literal: str

Perl literal representing False.

float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of IntegerWidthStrategies

integer_width_strategy: IntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'undef'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'perl'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Perl needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble computed from date/datetime/bool format.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = <function _format_perl_string_double>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

property true_literal: str

Perl literal representing True.

property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Php(*args: object, **kwargs: object)

PHP language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Php call style options.

KEYWORD = KeywordCallStyle(separator=': ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for Php.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
PHP = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for Php.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
PHP = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
OCTAL_C_STYLE = mappingproxy({'NONE': <function format_integer_octal_c_style>, 'UNDERSCORE': <function format_integer_octal_c_style>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for PHP.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for PHP.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = <function _build_backslash_formatter.<locals>._format>
SINGLE = <function format_string_backslash_single_minimal>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for PHP.

V8_1 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = KeywordCallStyle(separator=': ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.php'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Prepend PHP’s $ sigil so a {"$ref": "name"} argument renders as $name at the call site.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into PHP’s $obj->method form.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return a new ClassName constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'php'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (PHP needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (PHP needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ('<?php',)
string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = False
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

static validate_spec_for_data(data: Value) None

Reject inputs containing an empty mapping on PHP.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.PowerShell(*args: object, **kwargs: object)

PowerShell language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

PowerShell call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='<#', suffix=' #>')
HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for PowerShell.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for PowerShell.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for PowerShell.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for PowerShell.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for PowerShell.

V7 = 1
allows_empty_call_parens = False
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = '; '
empty_dict_keys

alias of EmptyDictKey

extension = '.ps1'
false_literal: ClassVar[str] = '$false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.PASCAL, IdentifierCase.CAMEL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = '$null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'powershell'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (PowerShell needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (PowerShell needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = False
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = '$true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.PureScript(*args: object, **kwargs: object)

PureScript language specification.

The generated output uses custom constructors (PNull, PBool, PList, PDict, PSet) that are not built-in PureScript types. To compile the generated code, define a Val ADT in the consuming module:

import Prelude

data Tuple a b = Tuple a b

data Val
    = PNull
    | PBool Boolean
    | PInt Int
    | PFloat Number
    | PStr String
    | PList (Array Val)
    | PDict (Array (Tuple String Val))
    | PSet (Array Val)

The body preamble automatically emits only the constructors that are actually used by the data.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.ISO — ISO 8601 string, e.g. PStr "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.ISO — ISO 8601 string, e.g. PStr "2024-01-15T12:30:00".

  • type_name – Name of the generated custom type. Defaults to "Val".

  • constructor_prefix – Prefix for generated constructor names. Defaults to "P", producing constructors like PNull, PBool, PInt, etc.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function _build_purescript_bytes_base64.<locals>._format>
HEX = <function _build_purescript_bytes_hex.<locals>._format>
class CallStyles(*values)

PureScript call style options.

COMMAND = CommandCallStyle(arg_separator=' ')
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='{-', suffix=' -}')
DOUBLE_DASH = CommentConfig(prefix='--', suffix='')
class DateFormats(*values)

Date format options for PureScript.

ISO = DateFormatConfig(formatter=<function _build_purescript_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for PureScript.

EPOCH = DatetimeFormatConfig(formatter=<function datetime_epoch_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function _build_purescript_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function _build_purescript_float_wrapper.<locals>._format>
REPR = <function _build_purescript_float_wrapper.<locals>._format>
SCIENTIFIC = <function _build_purescript_float_wrapper.<locals>._format>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = <function _build_purescript_integer_formatter.<locals>._format>
HEX = <function _build_purescript_integer_formatter.<locals>._format>
class JsonTypes(*values)

JSON value type options for PureScript.

ARGONAUT_JSON = 'Data.Argonaut.Core.Json'

Data.Argonaut.Core.Json – the dynamic JSON value type from the argonaut-core package.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for PureScript.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)
class SetFormats(*values)

Set type options for PureScript.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for PureScript.

V0_15 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function _build_purescript_bytes_hex.<locals>._format>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = CommandCallStyle(arg_separator=' ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='--', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

Under json_type the body preamble is reduced to the Data.Argonaut.Core, Data.Argonaut.Parser, and Data.Either imports needed by the jsonParser-backed binding, so the custom Val algebraic type and its Tuple helper are not emitted.

constructor_prefix: str = 'P'
property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function _build_purescript_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _build_purescript_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.purs'
property false_literal: str

False literal using the configured constructor prefix.

float_format: FloatFormats = <function _build_purescript_float_wrapper.<locals>._format>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Wrap each formatted call argument in parentheses.

Under json_type the argument is rendered as a Json value produced by jsonParser instead of the framework’s formatted Val literal.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

static format_call_binding_body_preamble() tuple[str, ...]

Module-internal preamble lines for an inference-bound call result.

The call stub returns Unit (make_widget _ = unit), so a wrap_in_file scaffold whose top level binds a call result must import Prelude to bring Unit / unit into scope. The literal binding for the same data needs no such import, so this is emitted only on the call-binding path.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

Under json_type the stub’s parameter types are Json rather than the generated Val ADT.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call expression.

The literal-binding declaration is prepended with a name :: Type annotation derived from the bound value’s runtime tagged-enum type (PInt, PStr, …); a call expression has no such tag, so the annotation is omitted and PureScript infers the call’s return type instead.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

Under json_type heterogeneous scalars all flow through the JSON text, so the framework’s scalar-uniformity checks are skipped.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = True
integer_format: IntegerFormats = <function _build_purescript_integer_formatter.<locals>._format>
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

property null_literal: str

Null literal using the configured constructor prefix.

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name: ClassVar[str | None] = None
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
scalar_body_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}
scalar_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}
sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = False
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

property true_literal: str

True literal using the configured constructor prefix.

property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

type_name: str = 'Val'
property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Raise if the spec cannot produce valid code for data.

Under json_type the data must round-trip through a JSON document, so walk data to reject non-string dict keys and non-finite floats – both inputs JSON cannot represent.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Wrap declarations and calls in a PureScript module.

Variable declarations go at module scope before main; call expressions are bound inside a let in unit block so that bare expressions are not required at the top level.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a PureScript value declaration in a module.

class literalizer.languages.Python(*args: object, **kwargs: object)

Python language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.PYTHONdatetime.date constructor call, e.g. datetime.date(year=2024, month=1, day=15).

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.PYTHONdatetime.datetime constructor call, e.g. datetime.datetime(year=2024, month=1, day=15, hour=12, minute=30, second=0).

    • datetime_formats.EPOCH — integer Unix epoch seconds, e.g. 1705312200.

  • bytes_format

    How to format bytes values.

    • bytes_formats.HEX — lowercase hex string, e.g. "48656c6c6f".

    • bytes_formats.PYTHON — Python bytes literal, e.g. b'Hello'.

  • sequence_format

    Which Python sequence type to use.

    • sequence_formats.TUPLE — tuple literal, e.g. (1, 2, 3).

    • sequence_formats.LIST — list literal, e.g. [1, 2, 3].

  • set_format

    Which Python set type to use.

    • set_formats.SET — mutable set literal, e.g. {1, 2, 3}.

    • set_formats.FROZENSET — immutable frozenset, e.g. frozenset({1, 2, 3}).

  • default_set_element_type – Type name used for empty set type hints. Defaults to "Any".

  • default_sequence_element_type – Type name used for empty list/tuple type hints. Defaults to "Any".

  • default_dict_key_type – Type name used for empty dict key type hints. Defaults to "str".

  • default_dict_value_type – Type name used for empty dict value type hints. Defaults to "Any".

  • variable_type_hints

    Whether to add inline type hints to variable declarations.

    • VariableTypeHints.NEVER — bare assignment, e.g. my_var = {...}. Empty collections still receive a type annotation so that type-checkers can infer the element types, e.g. my_var: dict[str, Any] = {}.

    • VariableTypeHints.ALWAYS — every declaration has a type annotation, e.g. my_var: dict[str, Any] = {...}.

  • language_version

    The minimum Python version to target.

    • VersionFormats.PY38 — use typing.List, typing.Dict, etc. for generic collection type hints (PEP 484 style).

    • VersionFormats.PY39 — use built-in list, dict, etc. directly as generic aliases (PEP 585, default).

  • heterogeneous_strategy

    How to render a record-shaped dict (non-empty, string-keyed).

    • HeterogeneousStrategies.ERROR — render a plain dict (default). Python’s dict is already heterogeneous, so every record-shaped dict is representable as one.

    • HeterogeneousStrategies.RECORD — opt-in idiomatic-output strategy: render each record-shaped dict as a generated frozen @dataclasses.dataclass declared in the preamble plus a matching RecordN(field=value, ...) literal. Every dict is still representable as a plain dict; this strategy only produces the more idiomatic dataclass form.

  • record_struct_name_prefix – Prefix for the auto-generated @dataclasses.dataclass names under the RECORD strategy ("Record" -> Record0, Record1, …).

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options for Python.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
PYTHON = <function _format_bytes_python>
property type_hint: str

The Python type hint for this bytes format.

class CallStyles(*values)

Call style options for Python.

KEYWORD = KeywordCallStyle(separator='=')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date formatting options for Python.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
PYTHON = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import datetime',), type_produced=<class 'datetime.date'>)
property type_hint: str

The Python type hint for this date format.

class DatetimeFormats(*values)

Datetime formatting options for Python.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
PYTHON = DatetimeFormatConfig(formatter=<function _format_datetime_python>, preamble_lines=('import datetime',), type_produced=<class 'datetime.datetime'>)
property type_hint: str

The Python type hint for this datetime format.

class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Strategy for dicts whose values span more than one Python type.

ERROR keeps the default behavior. Python’s dict is already heterogeneous, so a record-shaped dict is representable as a plain dict and is rendered that way by default. RECORD is an opt-in idiomatic-output strategy: each record-shaped dict (non-empty, string-keyed) becomes a generated frozen @dataclasses.dataclass declared in the preamble plus a matching RecordN(field=value, ...) literal. Every dict is still representable as a plain dict; this strategy only produces the more idiomatic dataclass form.

ERROR = 1
RECORD = 2
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Python.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=True, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property type_hint: str

Python type hint name for this sequence format.

class SetFormats(*values)

Set type options for Python.

FROZENSET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='})', empty_set='frozenset()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set='set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property type_hint: str

Python type hint name for this set format.

class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = <function _build_backslash_formatter.<locals>._format>
RAW = <function format_string_raw_python>
SINGLE = <function _build_backslash_formatter.<locals>._format>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options for Python.

ALWAYS = 2
NEVER = 1
SAFE = 3
formatter(*, bytes_hint: str, date_hint: str, datetime_hint: str, time_hint: str, sequence_hint: str, set_hint: str, dict_hint: str, default_set_element_type: str, default_sequence_element_type: str, default_dict_value_type: str, default_dict_key_type: str, join_union: Callable[[list[str]], str], record_eligible: Callable[[Value], bool]) Callable[[str, str, Value, frozenset[Enum]], str]

Return the variable declaration formatter for this hint style.

record_eligible flags RECORD-strategy record-shaped dicts so a bare assignment is kept for them (the generated dataclass already types every field); it is a constant False predicate for other strategies.

class VersionFormats(*values)

Python version to target.

This selects typing-alias syntax; it is not the runtime version floor. The floor under which the default fixtures are exercised in CI is governed by requires-python in pyproject.toml (>=3.12), not by this enum.

  • VersionFormats.PY38 — target Python 3.8; uses typing.List, typing.Dict, etc. for generic type hints, and emits datetime.timezone.utc for UTC.

  • VersionFormats.PY39 — uses built-in generic aliases list, dict, etc. (PEP 585, valid 3.9+). Note this variant also emits datetime.UTC, which requires Python 3.11+, so its true minimum interpreter is 3.11, not 3.9.

PY38 = 1
PY39 = 2
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = KeywordCallStyle(separator='=')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

Under HeterogeneousStrategies.RECORD emits import dataclasses followed by one frozen @dataclasses.dataclass declaration per record shape present in the data; otherwise produces no preamble.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import datetime',), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_python>, preamble_lines=('import datetime',), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

default_dict_key_type: str = 'str'
default_dict_value_type: str = 'Any'
default_sequence_element_type: str = 'Any'
default_set_element_type: str = 'Any'
dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.py'
false_literal: ClassVar[str] = 'False'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call result.

A literal binding adds an inline name: T = ... annotation for values whose type a checker cannot infer from the literal (empty collections, etc.). A call’s return type is opaque to the renderer – the annotation would be derived from the call’s argument data, not its result, and a strict checker rejects the mismatch – so the call result is bound with a plain name = value and the type is left to inference. Python has no declaration modifiers, so the modifier set is ignored.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the behavior for the chosen heterogeneous strategy.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = 1
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 2
property leading_preamble: LeadingPreamble

Emit the PEP 563 future import, but only when the rendered code actually contains an annotation.

from __future__ import annotations makes annotations lazy so generated files stay executable on Python 3.8+, but it serves no purpose (and misleads the reader) when nothing is annotated. An annotation is produced in exactly two cases:

  • the RECORD strategy generated one or more @dataclasses.dataclass blocks for the data (their fields are annotated), or

  • an inline variable type hint was produced – which only happens when a new variable is declared and either variable_type_hints is ALWAYS or the data needs a helper annotation (an empty collection; see _needs_type_annotation()).

The import must be the first statement in the module, so it is emitted via Language.leading_preamble rather than the data-dependent preamble (which follows other imports).

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'None'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'python'
record_struct_name_prefix: str = 'Record'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
scalar_body_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}
property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble computed from date/datetime format.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=True, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set='set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = True
supports_default_dict_value_type = True
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = True
supports_default_set_element_type = True
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = True
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'True'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Type-hint preamble computed from the configured default types.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap Python declaration + assignment in a valid file.

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap Python code in a valid file (no-op).

class literalizer.languages.R(*args: object, **kwargs: object)

R language specification.

Dicts are represented as named list() calls where each entry is written as "key" = value. R’s parser rejects zero-length names, so by default dict keys that are empty strings are emitted as positional (unnamed) list elements rather than as "" = value.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.Ras.Date(...) call, e.g. as.Date("2024-01-15").

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.Ras.POSIXct(...) call, e.g. as.POSIXct("2024-01-15T12:30:00").

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

  • empty_dict_key

    How to handle empty-string dict keys.

    • EmptyDictKey.POSITIONAL — emit as an unnamed positional list element.

    • EmptyDictKey.ERROR — raise InvalidDictKeyError.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

R call style options.

KEYWORD = KeywordCallStyle(separator=' = ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date formatting options for R.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
R = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime formatting options for R.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
R = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

How to handle empty-string dict keys in R.

R’s parser rejects zero-length names ("" = value is a parse error).

ERROR = <function _format_r_dict_entry_error>
POSITIONAL = <function _format_r_dict_entry_positional>
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = <class 'str'>
HEX = <function format_integer_hex>
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for R.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for R.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

R’s list() rejects empty arguments, so a literal trailing comma like list(1, 2,) parses but raises at runtime; only the comma-free form is supported.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for R.

V4 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = KeywordCallStyle(separator=' = ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_key: EmptyDictKey = <function _format_r_dict_entry_positional>
empty_dict_keys

alias of EmptyDictKey

extension = '.R'
false_literal: ClassVar[str] = 'FALSE'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = <class 'str'>
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'NULL'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'r'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (R needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (R needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = True
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'TRUE'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

static validate_spec_for_data(data: Value) None

Reject inputs containing an empty mapping on R.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Racket(*args: object, **kwargs: object)

Racket language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Racket call style options.

PREFIX_KEYWORD = PrefixCallStyle(arg_separator=' ', keyword_prefix='#:')
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='#|', suffix=' |#')
SEMICOLON = CommentConfig(prefix=';', suffix='')
class DateFormats(*values)

Date format options for Racket.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Racket.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

DEFINE = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Racket.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='(list)', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Racket.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set='(set)', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Racket.

V8 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PrefixCallStyle(arg_separator=' ', keyword_prefix='#:')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for Racket’s call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix=';', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ' '
empty_dict_keys

alias of EmptyDictKey

extension = '.rkt'
false_literal: ClassVar[str] = '#f'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Raise for any {"$ref": "name"} identifier.

Racket output is not wrapped in a function body, so identifier references require a surrounding define that cannot be injected.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.KEBAB, IdentifierCase.SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = '(void)'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'racket'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Racket needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Racket needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='(list)', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set='(set)', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ('#lang racket',)
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.KEBAB, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = '#t'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Raku(*args: object, **kwargs: object)

Raku language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.RAKUDate.new(...) call, e.g. Date.new(year => 2024, month => 1, day => 15).

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.RAKUDateTime.new(...) call, e.g. DateTime.new(year => 2024, month => 1, day => 15, hour => 12, minute => 30, second => 0, timezone => 0).

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00+00:00".

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Raku call style options.

KEYWORD = KeywordCallStyle(separator=' => ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for Raku.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
RAKU = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for Raku.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
RAKU = DatetimeFormatConfig(formatter=<function _format_datetime_raku>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

MY = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Raku.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Raku.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = <function _build_backslash_formatter.<locals>._format>
SINGLE = <function format_string_backslash_single_minimal>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Raku.

V6D = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_raku>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.raku'
false_literal: ClassVar[str] = 'False'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.KEBAB)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'Nil'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'raku'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
scalar_body_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}
property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble computed from date/datetime format.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = <function format_string_backslash_single_minimal>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.KEBAB, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = False
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'True'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Roc(*args: object, **kwargs: object)

Roc language specification.

The generated output uses custom tag constructors (RNull, RBool, RList, RDict, RSet) that are wrapped in a Val tag-union type alias emitted in the body preamble. For example, data consisting solely of an integer yields:

Val : [
    RInt I128,
]
Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.ISO — ISO 8601 string, e.g. RStr "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.ISO — ISO 8601 string, e.g. RStr "2024-01-15T12:30:00".

  • type_name – Name of the generated tag-union alias. Defaults to "Val".

  • constructor_prefix – Prefix for generated constructor names. Defaults to "R", producing constructors like RNull, RBool, RInt, etc.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function _build_roc_bytes_base64.<locals>._format>
HEX = <function _build_roc_bytes_hex.<locals>._format>
class CallStyles(*values)

Roc call style options.

COMMAND = CommandCallStyle(arg_separator=' ')
class CommentFormats(*values)

Comment style options.

HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for Roc.

ISO = DateFormatConfig(formatter=<function _build_roc_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Roc.

EPOCH = DatetimeFormatConfig(formatter=<function datetime_epoch_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function _build_roc_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function _build_roc_float_formatter.<locals>._format>
REPR = <function _build_roc_float_formatter.<locals>._format>
SCIENTIFIC = <function _build_roc_float_formatter.<locals>._format>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

BINARY = <function _build_roc_integer_formatter.<locals>._format>
DECIMAL = <function _build_roc_integer_formatter.<locals>._format>
HEX = <function _build_roc_integer_formatter.<locals>._format>
OCTAL = <function _build_roc_integer_formatter.<locals>._format>
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Roc.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Roc.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

NONE = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Roc.

V0 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function _build_roc_bytes_hex.<locals>._format>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = CommandCallStyle(arg_separator=' ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the Roc call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Emit the tag-union type alias for the types present in the data — placed inside wrap_in_file() so it sits after the module header.

constructor_prefix: str = 'R'
property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines (none for Roc — the type alias is emitted via compute_body_preamble() so it sits after the module header inside wrap_in_file()).

date_format: DateFormats = DateFormatConfig(formatter=<function _build_roc_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _build_roc_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.roc'
property false_literal: str

Literal representing False.

float_format: FloatFormats = <function _build_roc_float_formatter.<locals>._format>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Wrap each call argument in parentheses for the Roc space-separated call syntax.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression — emitted via body_preamble so they sit after the module header.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into a Roc identifier.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call expression.

The literal-binding declaration emits a name : Val annotation derived from the bound value’s runtime tag-union type; a call expression has no such tag, so the annotation is omitted and Roc infers the call’s return type instead.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = True
integer_format: IntegerFormats = <function _build_roc_integer_formatter.<locals>._format>
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

property null_literal: str

Literal representing None.

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'text'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Roc needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Roc needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = False
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = False
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

property true_literal: str

Literal representing True.

property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

type_name: str = 'Val'
property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Wrap Roc declarations and call expressions in a module.

Declarations (variable bindings spanning multiple lines) are kept verbatim at module scope alongside the Val type alias and call stubs; only the top-level call lines inside main are wrapped in dbg (...).

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a Roc value declaration in a module.

The module exposes variable_name (or main when empty, in call mode) so the file is a syntactically valid Roc module. Body-preamble lines (the Val type alias and any call stubs) sit at module scope after the header. In call mode each top-level call expression is wrapped in dbg (...) inside main: a plain _ = pure_call would trip the Roc UNNECESSARY DEFINITION warning, which roc check exits non-zero on, whereas dbg is treated as side effecting.

The Val type alias is kept only when the wrapped output actually annotates a binding with : Val (the literal-binding declaration my_data : Val). It is dropped for every call mode – both the discarded-result form (exposed main) and the inference-style call binding my_data = make_widget ... whose right-hand side is a call expression with no tag, hence no annotation. Keeping an alias nothing uses would trip the Roc UNUSED DEFINITION warning, which roc check exits non-zero on, when the alias has no recursive (List/Dict/Set) self-reference for the compiler to consider load-bearing.

class literalizer.languages.Ruby(*args: object, **kwargs: object)

Ruby language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.RUBYDate.new(...) call, e.g. Date.new(2024, 1, 15).

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.RUBYTime.new(...) call, e.g. Time.new(2024, 1, 15, 12, 30, 0).

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

  • dict_entry_style

    How to format dict/hash entries.

    • dict_entry_styles.ROCKET — rocket notation, e.g. "name" => "Alice".

    • dict_entry_styles.SYMBOL — symbol notation, e.g. name: "Alice".

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Ruby call style options.

KEYWORD = KeywordCallStyle(separator=': ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for Ruby.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
RUBY = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=("require 'date'",), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for Ruby.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
RUBY = DatetimeFormatConfig(formatter=<function _format_datetime_ruby>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options for Ruby.

  • ROCKET — rocket notation, e.g. "key" => "value".

  • SYMBOL — symbol notation, e.g. key: "value".

ROCKET = (<function dict_entry_with_separator.<locals>._format>,)
SYMBOL = (<function dict_entry_symbol_style.<locals>._format>,)
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Ruby.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Ruby.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='Set.new', preamble_lines=("require 'set'",), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = <function _build_backslash_formatter.<locals>._format>
SINGLE = <function format_string_backslash_single_minimal>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Ruby.

V3 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = KeywordCallStyle(separator=': ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=("require 'date'",), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_ruby>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = (<function dict_entry_with_separator.<locals>._format>,)
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.rb'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} call-argument identifier.

Unlike format_call_ref_identifier, this is used only when the $ref appears as a direct call argument (via literalize_call()). In that context the referenced variable has already been emitted at the same top-level scope, so the reference is valid.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Raise for any {"$ref": "name"} identifier.

Ruby output is not wrapped in a function body; variable references require a surrounding assignment that cannot be injected via the call framework.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return a Ruby ClassName.new constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE, IdentifierCase.PASCAL)
indent: str = '  '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'nil'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'ruby'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Ruby needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble computed from date/datetime format.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='Set.new', preamble_lines=("require 'set'",), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Rust(*args: object, **kwargs: object)

Rust language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.RUSTNaiveDate::from_ymd_opt(...) call, e.g. NaiveDate::from_ymd_opt(2024, 1, 15).unwrap(). Requires the chrono crate.

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.RUSTNaiveDateTime::new(...) call, e.g. NaiveDateTime::new(NaiveDate::from_ymd_opt(2024, 1, 15) .unwrap(), NaiveTime::from_hms_opt(12, 30, 0).unwrap()). Requires the chrono crate.

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

  • sequence_format

    Which Rust sequence type to use.

    • sequence_formats.VECvec![] macro, e.g. vec![1, 2, 3]. Because Vec is homogeneous, heterogeneous-scalar inputs raise.

    • sequence_formats.ARRAY — fixed-size array literal, e.g. [1, 2, 3]. Because Rust arrays are homogeneous, heterogeneous-scalar inputs raise.

    • sequence_formats.TUPLE — tuple literal, e.g. (1, 2, 3).

  • default_sequence_element_type – Type name used for empty Vec literals, e.g. Vec::<String>::new(). Defaults to "String".

  • json_type – When set to json_types.SERDE_JSON_VALUE, render values through serde_json::json! instead of Rust’s narrow collection types.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Rust call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for Rust.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
RUST = DateFormatConfig(formatter=<function _format_date_rust>, preamble_lines=('use chrono::NaiveDate;',), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for Rust.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
RUST = DatetimeFormatConfig(formatter=<function _format_datetime_rust>, preamble_lines=('use chrono::NaiveDate;', 'use chrono::NaiveDateTime;', 'use chrono::NaiveTime;'), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

CONST = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
LAZY_STATIC = DeclarationStyleConfig(formatter=<function _lazy_static_placeholder_formatter>, supports_redefinition=False)
LET = DeclarationStyleConfig(formatter=<function _format_let_declaration>, supports_redefinition=False)
LET_MUT = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
STATIC = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
build_formatter(*, date_type: str, datetime_type: str, sequence_format_type_annotation: Callable[[str, int], str], sequence_supports_heterogeneity: bool, set_format_type_annotation: Callable[[str], str], dict_format_type_annotation: Callable[[str, str], str], default_sequence_element_type: str, default_set_element_type: str, default_dict_key_type: str, default_dict_value_type: str) Callable[[str, str, Value, frozenset[Enum]], str]

Return a formatter for this declaration style.

For LET and LET_MUT the formatter is used directly. For CONST and STATIC a type-annotated formatter is built from the language configuration. LAZY_STATIC additionally wraps the inferred type in LazyLock<…> and the value in a LazyLock::new(|| …) call, enabling module-level declarations of runtime-initialized collections like HashMap and Vec.

class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

BTREE_MAP = <function dict_format_factory.<locals>._build>
HASH_MAP = <function dict_format_factory.<locals>._build>
format_type_annotation(key_type: str, value_type: str) str

Return the Rust type annotation for this dict format.

class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Strategy for representing dicts or lists whose scalar values span more than one Rust type.

ERROR = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)

Raise HeterogeneousScalarCollectionError (or HeterogeneousSiblingListsError) when scalar values of mixed types appear in a container that cannot represent them. This is the default, matching Rust’s strict-typing convention.

RECORD = _HeterogeneousStrategyConfig(build_behavior=<function _build_record_behavior>, build_preamble=<function _build_record_preamble>)

Render record-shaped dicts (non-empty, string-keyed) as generated struct literals.

Each distinct ordered-key tuple becomes a struct declared in the preamble (struct Record0 { field: Type, ... }) and each matching dict in the data renders as a struct literal (Record0 { field: value, ... }) rather than a HashMap::from([...]) call. Useful for inputs whose dict values span multiple Rust scalar types but always share the same field set. The prefix is configurable via Rust.record_struct_name_prefix.

TAGGED_ENUM = _HeterogeneousStrategyConfig(build_behavior=<function _build_tagged_enum_behavior>, build_preamble=<function _build_tagged_enum_preamble>)

Auto-generate a tagged enum in the preamble containing only the variants actually present in the data, and wrap each heterogeneous scalar value with {EnumName}::{Variant}(value).

Integer variants use narrowest-width names (I32, I64, I128) matching Rust’s default integer-type inference. The enum name is configurable via Rust.heterogeneous_value_enum_name.

TUPLE = _HeterogeneousStrategyConfig(build_behavior=<function _build_tuple_behavior>, build_preamble=<function _build_tuple_preamble>)

Render a fixed-length heterogeneous scalar array (a dict value, record field value, or the document root, all elements scalar and spanning at least two scalar buckets) as a native Rust tuple (e0, e1, ...) typed (T0, T1, ...) instead of rejecting it.

Composes with RECORD: a record field whose value is such an array becomes a tuple-typed struct field (e.g. struct Record0 { call: &'static str, args: (i32, &'static str, &'static str, i32) }). Heterogeneous arrays nested inside another list, or containing a non-scalar element, are out of scope and still raise. Rust tuples have no length limit.

class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(*values)

JSON value type options for Rust.

SERDE_JSON_VALUE = 'serde_json::Value'

Serde’s dynamic JSON value type.

Modifiers

alias of _RustModifiers

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Rust.

ARRAY = <function sequence_format_factory.<locals>._build>
TUPLE = <function sequence_format_factory.<locals>._build>
VEC = <function sequence_format_factory.<locals>._build>
format_type_annotation(element_type: str, length: int) str

Return the Rust type annotation for this format.

property supports_heterogeneity: bool

Whether this sequence format supports mixed-type elements.

class SetFormats(*values)

Set type options for Rust.

BTREE_SET = <function set_format_factory.<locals>._build>
HASH_SET = <function set_format_factory.<locals>._build>
format_type_annotation(element_type: str) str

Return the Rust type annotation for this set format.

class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = <function _build_backslash_formatter.<locals>._format>
RAW = <function format_string_raw_rust>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Rust.

EDITION_2021 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

For HeterogeneousStrategies.TAGGED_ENUM emits a minimal enum declaration listing only the variants actually used in heterogeneous positions in the data. For HeterogeneousStrategies.RECORD emits one struct declaration per record shape present in the data. Other strategies produce no preamble.

date_format: DateFormats = DateFormatConfig(formatter=<function _format_date_rust>, preamble_lines=('use chrono::NaiveDate;',), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_rust>, preamble_lines=('use chrono::NaiveDate;', 'use chrono::NaiveDateTime;', 'use chrono::NaiveTime;'), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_let_declaration>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

default_dict_key_type: str = 'String'
default_dict_value_type: str = 'String'
default_sequence_element_type: str = 'String'
default_set_element_type: str = 'String'
dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = <function dict_format_factory.<locals>._build>
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = False
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.rs'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return a Rust ClassName::new constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

Rust’s widest built-in integer types are i128/u128; values outside the signed i128 range have no native literal form, so raise UnrepresentableIntegerError rather than emit a literal rustc will reject.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the behavior for the chosen heterogeneous strategy.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)
heterogeneous_value_enum_name: str = 'Value'
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of _RustModifiers

property null_literal: str

Null literal for the active Rust representation.

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'rust'
record_shape_names: Mapping[frozenset[str], str]
record_struct_name_prefix: str = 'Record'
record_unify_optional_fields: bool = False
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
scalar_body_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}
property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble computed from date/datetime format.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = <function sequence_format_factory.<locals>._build>
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = <function set_format_factory.<locals>._build>
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
property static_preamble: Sequence[str]

Static preamble lines emitted once per file.

LAZY_STATIC adds use std::sync::LazyLock;; other declaration styles produce no static preamble.

string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = True
supports_default_dict_value_type = True
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = True
supports_default_set_element_type = True
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = True
supports_record_shape_names = True
supports_record_struct_name_prefix = True
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Validate Rust-specific data/format combinations.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap Rust declaration + assignment in a main function.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a Rust let binding in a main function.

class literalizer.languages.Scala(*args: object, **kwargs: object)

Scala language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Scala call style options.

KEYWORD = KeywordCallStyle(separator=' = ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for Scala.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
SCALA = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDate',), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for Scala.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
SCALA = DatetimeFormatConfig(formatter=<function _format_datetime_scala>, preamble_lines=('import java.time.ZoneId', 'import java.time.ZonedDateTime'), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

VAL = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

LIST_MAP = _ScalaDictSpec(opener_template='ListMap[String, {type_name}](', fallback='ListMap(', preamble_lines=('import scala.collection.immutable.ListMap',))
MAP = _ScalaDictSpec(opener_template='Map[String, {type_name}](', fallback='Map(', preamble_lines=())
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Strategy for dicts whose values span more than one Scala type.

ERROR keeps Scala’s strict-typing behavior (mixed-value dicts that cannot be represented raise). RECORD renders each record-shaped dict (non-empty, string-keyed) as a generated case class declared in the preamble plus a matching Record0(field = value, ...) literal, so fields may legitimately mix scalars and containers. TUPLE composes RECORD and additionally renders each fixed-length heterogeneous scalar array (a record field, another dict value, or the document root) as a native tuple (e0, e1, ...) typed (T0, T1, ...). Scala 3 imposes no tuple-length limit (lengths past 22 are transparently backed by TupleXXL), so any fixed-length heterogeneous scalar array is representable.

ERROR = 1
RECORD = 2
TUPLE = 3
class IntegerFormats(*values)

Integer format options.

DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(*values)

JSON value type options for Scala.

CIRCE = 'io.circe.Json'

Circe’s io.circe.Json dynamic JSON value type.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Scala.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='Array.empty[Any]', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback='Array(', uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
SEQ = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Scala.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
TREE_SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set='TreeSet.empty[Int]', preamble_lines=('import scala.collection.immutable.TreeSet',), set_opener_template='TreeSet[{type_name}](', supports_heterogeneity=False, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Scala.

V3 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = KeywordCallStyle(separator=' = ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map, prefixed with the RECORD strategy’s generated case class declarations.

Scala compiles every fixture in one invocation, so a file-scope case class Record0 would collide across cases. Emitting the declarations into the body preamble (which wrap_in_file() places inside the per-fixture object, ahead of the value) scopes each RecordN to its own fixture; the declarations precede the scalar body lines so a record type is in scope before its literal.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

The RECORD strategy’s case class declarations are not emitted here (file scope): Scala compiles every fixture together, so a file-scope case class Record0 would collide across cases. They are emitted into the per-fixture object body instead; see compute_body_preamble.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDate',), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_scala>, preamble_lines=('import java.time.ZoneId', 'import java.time.ZonedDateTime'), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = _ScalaDictSpec(opener_template='Map[String, {type_name}](', fallback='Map(', preamble_lines=())
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.scala'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return a new ClassName constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

EPOCH seconds are routed through format_integer so a post-2038 value carries the L suffix Scala requires for an integer literal outside 32-bit range: a bare 4085195400 is rejected by the compiler as “number too large” even when the target type is Long. In-range epoch seconds format identically to the plain integer, so every checked-in golden file stays byte-identical.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the behavior for the chosen heterogeneous strategy.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = 1
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

module_name: str = 'Check'
module_name_case: ClassVar[IdentifierCase] = 'pascal'
null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'scala'
record_shape_names: Mapping[frozenset[str], str]
record_struct_name_prefix: str = 'Record'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
scalar_body_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}
property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble computed from date/datetime format.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

Under the RECORD strategy (and TUPLE, which composes it) a list whose elements are record-shaped dicts is opened with the format’s plain, element-type-free opener (List() so the elements render as RecordN(...) literals and Scala infers List[RecordN]; the typed opener would otherwise infer a Map[String, ...] element type that the struct literals do not satisfy.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
property static_preamble: Sequence[str]

Static preamble lines emitted once per file.

Circe-backed Scala output needs io.circe.Json in scope so the Json.obj / Json.arr factories the rendered literal uses resolve.

string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = True
supports_record_struct_name_prefix = True
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Validate Scala-specific data/format combinations.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap Scala declaration + assignment in an object.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a Scala declaration in an object.

class literalizer.languages.Scheme(*args: object, **kwargs: object)

Scheme language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Scheme call style options.

PREFIX = PrefixCallStyle(arg_separator=' ', keyword_prefix='')
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='#|', suffix=' |#')
SEMICOLON = CommentConfig(prefix=';', suffix='')
class DateFormats(*values)

Date format options for Scheme.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Scheme.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

DEFINE = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(*values)

JSON value type options for Scheme.

GUILE_JSON = 'guile-json scm->json value shape'

Scheme association lists for objects, vectors for arrays, 'null for JSON null. The literalized output can be handed directly to (scm->json ...) without a runtime shape walker.

Type:

Guile-json’s scm->json value shape

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Scheme.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='(list)', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Scheme.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set='(list)', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Scheme.

R7RS = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PrefixCallStyle(arg_separator=' ', keyword_prefix='')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Return the active call-style configuration.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix=';', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

Each entry is a (cons "k" v) pair and the dict wraps them in (list ...) to form a Scheme association list – the conventional key/value mapping idiom, what assoc / alist->hash-table expect, and what scm->json’s json-valid? accepts for JSON objects under json_type. A list of pair? elements is locally distinguishable from a heterogeneous sequence, unlike the legacy flat (list "k" v "k" v ...) form.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ' '
empty_dict_keys

alias of EmptyDictKey

extension = '.scm'
false_literal: ClassVar[str] = '#f'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Raise for any {"$ref": "name"} identifier.

Scheme output is not wrapped in a function body; variable references require a surrounding define that cannot be injected via the call framework.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

Each entry is a (cons "k" v) pair matching dict_format_config.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.KEBAB,)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

property null_literal: str

The literal representing null.

Under json_type the value must be the null sentinel that guile-json recognizes (the symbol 'null, matching the default of its *null* parameter); the flat-list mode uses the empty list, which is conventional for null in Scheme.

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

Under json_type an ordered map is rendered as the same association-list shape used for plain dicts so scm->json round-trips it as a JSON object (key order is preserved by the surrounding list’s element order).

pygments_name = 'scheme'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Scheme needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Scheme needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='(list)', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

Under json_type arrays are emitted as (vector ...) so scm->json round-trips them as JSON arrays unambiguously.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set='(list)', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

Under json_type sets share the array form ((vector ...)); JSON has no native set type.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
property static_preamble: Sequence[str]

File-scope preamble.

Under json_type the rendered value is a tree of Scheme association lists and vectors that (scm->json ...) accepts directly, so the (json) module must be imported.

string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.KEBAB, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = '#t'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Reject data that json_type=GUILE_JSON cannot represent.

Walks data under json_type to reject non-string dict keys (JSON objects keys must be strings) and the special floats NaN / +inf.0 / -inf.0 (not valid JSON).

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Sml(*args: object, **kwargs: object)

Standard ML language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.SML — tuple literal, e.g. (2024, 1, 15).

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.SML — pair of tuples, e.g. ((2024, 1, 15), (12, 30, 0)).

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

  • type_name – Name of the generated custom type. Defaults to "val_t".

  • constructor_prefix – Prefix for generated constructor names. Defaults to "S", producing constructors like SNull, SBool, SInt, etc.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Sml call style options.

CURRIED = CommandCallStyle(arg_separator=' ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

PAREN_STAR = CommentConfig(prefix='(*', suffix=' *)')
class DateFormats(*values)

Date format options for Standard ML.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
SML = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for Standard ML.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
SML = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

VAL = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function _sml_negate_float.<locals>._format>
REPR = <function _sml_negate_float.<locals>._format>
SCIENTIFIC = <function _sml_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = mappingproxy({'NONE': <function _sml_negate_int.<locals>._format>})
HEX = mappingproxy({'NONE': <function _sml_negate_int.<locals>._format>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Standard ML.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='val_t', narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Standard ML.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for SML.

SML_97 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='(*', suffix=' *)')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

constructor_prefix: str = 'S'
property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.sml'
property false_literal: str

Literal for the false value.

float_format: FloatFormats = <function _sml_negate_float.<locals>._format>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Callable that rewrites a formatted direct call argument.

Curried calls parenthesize each argument so that constructor applications are not parsed as additional arguments to the outer call.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Wrap a call expression as a val binding so it is a valid SML declaration inside a structure block.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call expression.

The literal-binding declaration is prepended with a : val_t type annotation and wraps the value in a datatype constructor derived from the bound value’s runtime type; a call expression has no such tag, so both are omitted and SML infers the call’s return type instead.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Callable that formats a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Callable that formats a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL, IdentifierCase.PASCAL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <function _sml_negate_int.<locals>._format>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

property null_literal: str

Literal for the null value.

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'sml'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({'op'})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble for SML datatype declarations.

scalar_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}
sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='val_t', narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

property true_literal: str

Literal for the true value.

property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

type_name: str = 'val_t'
property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap an SML val declaration at top level.

class literalizer.languages.Swift(*args: object, **kwargs: object)

Swift language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Swift call style options.

KEYWORD = KeywordCallStyle(separator=': ')
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for Swift.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
SWIFT = DateFormatConfig(formatter=<function _format_date_swift>, preamble_lines=('import Foundation',), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for Swift.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
SWIFT = DatetimeFormatConfig(formatter=<function _format_datetime_swift>, preamble_lines=('import Foundation',), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = <function dict_format_factory.<locals>._build>
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options.

Swift represents heterogeneous collections with Any by default (ERROR). RECORD instead renders each record-shaped dict (non-empty, string-keyed) as a generated struct declared in the preamble plus a matching Record0(field: value, ...) initializer literal, so a record-shaped dict that mixes scalars with a container is representable as a typed value even though Dictionary requires a homogeneous value type.

ERROR = 1
RECORD = 2
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Swift.

ARRAY = <function sequence_format_factory.<locals>._build>
TUPLE = <function sequence_format_factory.<locals>._build>
class SetFormats(*values)

Set type options for Swift.

SET = <function set_format_factory.<locals>._build>
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

ALWAYS = 2
NEVER = 1
SAFE = 3
formatter(*, auto_formatter: Callable[[str, str, Value, frozenset[Enum]], str], keyword: str, date_hint: str, datetime_hint: str, default_set_element_type: str, default_sequence_element_type: str, default_dict_value_type: str, sequence_is_tuple: bool) Callable[[str, str, Value, frozenset[Enum]], str]

Return the variable declaration formatter.

class VersionFormats(*values)

Version options for Swift.

V5_9 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = KeywordCallStyle(separator=': ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

Under HeterogeneousStrategies.RECORD this emits one struct declaration per record shape present in the data; otherwise no data-dependent lines.

date_format: DateFormats = DateFormatConfig(formatter=<function _format_date_swift>, preamble_lines=('import Foundation',), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_swift>, preamble_lines=('import Foundation',), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

default_dict_key_type: str = 'String'
default_dict_value_type: str = 'Any'
default_sequence_element_type: str = 'Any'
default_set_element_type: str = 'AnyHashable'
dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = <function dict_format_factory.<locals>._build>
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.swift'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Callable that formats a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the behavior for the chosen heterogeneous strategy.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = 1
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'nil'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'swift'
record_struct_name_prefix: str = 'Record'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
scalar_body_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}
property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble computed from date/datetime format.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = <function sequence_format_factory.<locals>._build>
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = <function set_format_factory.<locals>._build>
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = True
supports_default_dict_value_type = True
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = True
supports_default_set_element_type = True
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = True
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.SystemVerilog(*args: object, **kwargs: object)

SystemVerilog language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

SystemVerilog call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for SystemVerilog.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for SystemVerilog.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

TYPED = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = <function _format_integer_decimal_sv>
HEX = <function _format_integer_hex_sv>
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for SystemVerilog.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence="'{}", preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for SystemVerilog.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set="'{}", preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for SystemVerilog.

IEEE_1800_2017 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.sv'
false_literal: ClassVar[str] = '_VVal\'{tag: _VVAL_INT, i: 0, r: 0.0, s: ""}'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Wrap each call argument in the _VVal struct literal.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Emit a call-argument $ref as the bare identifier.

Call arguments have their type fixed by the function signature, so the scalar/dict shape mismatch that affects format_call_ref_identifier (top-level $ref in literalize()) does not arise here.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax, rejecting scalar refs.

SystemVerilog’s variable declarations key the type off the marker mapping shape (_VKV name[]), so a top-level ref pointing to a scalar produces a typed declaration that does not match the referenced _VVal variable. Refuse those cases so the renderer fails fast instead of emitting code that the SystemVerilog compiler rejects with “types are not assignment compatible”.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment binding a call result.

The call-expression counterpart of format_variable_assignment; the _VVal struct-literal wrapping is dropped since the call already yields a _VVal.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call result.

A literal binding wraps the right-hand side in a named _VVal struct literal derived from the parsed value’s runtime type; a call’s return type is opaque to the renderer and is always the universal _VVal struct (the type every generated value-returning call stub returns), so the call result is bound directly with a plain static _VVal declaration and no struct-literal wrapping.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = <function _format_integer_decimal_sv>
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

module_name: str = 'Module'
module_name_case: ClassVar[IdentifierCase] = 'snake'
null_literal: ClassVar[str] = '_VVal\'{tag: _VVAL_STR, i: 0, r: 0.0, s: ""}'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'systemverilog'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
scalar_body_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}
scalar_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}
sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence="'{}", preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set="'{}", preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ('typedef enum int {_VVAL_INT, _VVAL_REAL, _VVAL_STR} _VTag;\ntypedef struct {\n    _VTag tag;\n    longint i;\n    real r;\n    string s;\n} _VVal;\ntypedef struct {\n    string k;\n    _VVal v;\n} _VKV;',)
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = False
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = True
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = '_VVal\'{tag: _VVAL_INT, i: 1, r: 0.0, s: ""}'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_call_variable_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a call-result variable binding in a SystemVerilog module.

In wrap_in_file()’s variable_name branch, body_preamble is prepended inside initial begin (where, for a literal binding, it is data-dependent preamble). For a call binding those lines are instead the module-scope task/function/ class stubs emitted by _sv_call_stub(), and a function declared inside initial begin is illegal. Place the stubs at module scope (matching the call-without-binding branch of wrap_in_file()) while keeping the static _VVal my_data = make_widget(...); binding inside initial begin.

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap SystemVerilog declaration + assignment in a module.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a SystemVerilog declaration in a module.

In call mode (variable_name is empty), body_preamble holds task/function stubs that go at module scope outside initial begin. In declaration mode, body_preamble is prepended inside initial begin as usual.

class literalizer.languages.Tcl(*args: object, **kwargs: object)

Tcl language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Tcl call style options.

COMMAND = CommandCallStyle(arg_separator=' ')
class CommentFormats(*values)

Comment style options.

HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

SET = DeclarationStyleConfig(formatter=<function _format_tcl_declaration>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options.

DICT = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = <function _build_backslash_formatter.<locals>._format>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Tcl.

V8_6 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = CommandCallStyle(arg_separator=' ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_tcl_declaration>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ' '
empty_dict_keys

alias of EmptyDictKey

extension = '.tcl'
false_literal: ClassVar[str] = '0'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment binding a call expression.

set is the only binding form in this language, so an existing-variable assignment shares the command-substitution template with format_call_variable_declaration.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call expression.

The literal-binding template emits the right-hand side as a value word; a call result must be command-substituted with [...] so Tcl runs the command instead of treating its name and arguments as a literal list.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Format one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = '""'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'tcl'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Tcl needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Tcl needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = False
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = '1'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Toml(*args: object, **kwargs: object)

TOML language specification.

Produces TOML inline values — inline tables for mappings, and arrays for sequences and sets — using TOML v1.1 multiline inline table syntax, which permits newlines and comments within braces.

null is not a TOML type; dict entries whose value is null are omitted (skip_null_dict_values = True), and null values in sequences are rendered as the empty string "".

Dates and datetimes are rendered as unquoted TOML native date / datetime literals, which are a distinct TOML type.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Toml call style options.

class CommentFormats(*values)

Comment style options.

HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for Toml.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
TOML = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for Toml.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
TOML = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for TOML.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for TOML.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for TOML.

V1 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style_config: ClassVar[PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle | CallSupport] = 'not_in_language'
call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.toml'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Raise for any {"$ref": "name"} identifier.

TOML is a data format; values must be literals, not variable references, so refs are not supported.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Format one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE,)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = '""'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'toml'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (TOML needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (TOML needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = True
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = False
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.TypeScript(*args: object, **kwargs: object)

TypeScript language specification.

Parameters:
  • date_format

    How to format datetime.date values.

    • date_formats.JSnew Date(...) call, e.g. new Date("2024-01-15").

    • date_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15".

  • datetime_format

    How to format datetime.datetime values.

    • datetime_formats.JSnew Date(...) call, e.g. new Date("2024-01-15T12:30:00").

    • datetime_formats.ISO — ISO 8601 quoted string, e.g. "2024-01-15T12:30:00".

  • sequence_format

    Which TypeScript sequence type to use.

    • sequence_formats.ARRAY — array literal, e.g. [1, 2, 3].

    • sequence_formats.TUPLEas const tuple literal, e.g. [1, 2, 3] as const. TypeScript infers per-element types instead of a union array type.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

TypeScript call style options.

OBJECT = ObjectCallStyle(separator=': ')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date formatting options for TypeScript.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
JS = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime formatting options for TypeScript.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
JS = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

CONST = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

MAP = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close='])', format_entry=<function dict_entry_with_template.<locals>._format>, empty_dict='new Map()', preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)
OBJECT = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close='}', format_entry=<function dict_entry_with_separator.<locals>._format>, empty_dict=None, preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options.

TypeScript represents heterogeneous scalar collections with union element / value types by default (ERROR); TUPLE additionally renders a fixed-length heterogeneous scalar array (a dict value or the document root, all elements scalar, spanning at least two scalar buckets) as an [e0, e1, ...] as const tuple literal, which TypeScript infers as a readonly [T0, T1, ...] tuple type.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
TUPLE = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=<function _render_ts_tuple>, compute_tuple_list_ids=<function _ts_tuple_list_ids>)
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for TypeScript.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='] as const', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='[] as const', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for TypeScript.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='new Set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

NONE = 'none'
SEMICOLON = 1
wrap_formatter(formatter: Callable[[str, str, Value, frozenset[Enum]], str]) Callable[[str, str, Value, frozenset[Enum]], str]

Wrap a formatter to match this statement terminator style.

class StringFormats(*values)

String format options.

DOUBLE = <function _build_backslash_formatter.<locals>._format>
SINGLE = <function _build_backslash_formatter.<locals>._format>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

ALWAYS = 2
NEVER = 1
SAFE = 3
formatter(*, auto_formatter: Callable[[str, str, Value, frozenset[Enum]], str], keyword: str, date_hint: str, datetime_hint: str, dict_hint_template: str, sequence_is_tuple: bool) Callable[[str, str, Value, frozenset[Enum]], str]

Return the variable declaration formatter.

class VersionFormats(*values)

Version options for TypeScript.

V5 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = ObjectCallStyle(separator=': ')
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close='}', format_entry=<function dict_entry_with_separator.<locals>._format>, empty_dict=None, preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.ts'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call result.

The input row describes call arguments, not the call’s return type, so TypeScript call-result bindings intentionally rely on inference instead of reusing literal-derived annotations.

static format_constructor_target(class_name: str, /) str

Return a new ClassName constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

JavaScript’s number is an IEEE 754 double whose integer precision tops out at Number.MAX_SAFE_INTEGER (2**53 - 1). Above that, a bare numeric literal silently loses precision on parse, so reject the value at literalize time with UnrepresentableIntegerError rather than emit a literal that no longer round-trips. Wrapping such values in a BigInt literal (99n) is a separate strategy not yet offered for TypeScript.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)
indent: str = '  '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'typescript'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (TypeScript needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (TypeScript needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='new Set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap TypeScript declaration + assignment as a module.

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a TypeScript declaration as a module.

class literalizer.languages.V(*args: object, **kwargs: object)

V language specification.

Parameters:

declaration_style

How to declare variables.

  • declaration_styles.ASSIGN — immutable short declaration, e.g. x := value.

  • declaration_styles.MUT — mutable short declaration, e.g. mut x := value.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

V call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for V.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for V.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
MUT = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options for V.

ERROR = 1

Raise on heterogeneous scalar collections (default).

V is statically typed and rejects unwrapped heterogeneous collections, so the default refuses to render them rather than emit code the V compiler will not accept. Callers that want to materialize such data must opt in to INTERFACE or RECORD.

Still emits interface IVal {} when the data contains an empty list, dict, or set, because the empty-literal rendering ([]IVal{} / map[string]IVal{}) references it regardless of strategy.

INTERFACE = 2

Wrap heterogeneous scalars and null values with IVal(...) and emit interface IVal {} in the file preamble.

RECORD = 3

Render each record-shaped dict (non-empty, string-keyed) as a generated file-scope struct plus a matching Record0{ field: value, ... } literal, so a dict may mix scalars and containers that a homogeneous map[string]V cannot.

The behavior and preamble are resolved per instance from _record_strategy (the shared record behavior needs the per-instance renderer, so it cannot be stored on the enum member).

class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for V.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=False, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='[]IVal{}', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=<function make_narrowed_empty_form.<locals>._narrowed_empty_form>)
class SetFormats(*values)

Set type options for V.

ARRAY = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set='[]IVal{}', preamble_lines=(), set_opener_template='', supports_heterogeneity=False, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

NEWLINE = 1
class StringFormats(*values)

String format options.

SINGLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for V.

V0_4 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Return the active call-style configuration.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for the chosen strategy.

RECORD emits the interface IVal {} line (when an empty container references it) followed by one struct declaration per record shape; INTERFACE emits the interface when any container needs wrapping; ERROR emits the interface only for an empty-collection literal.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = False
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.v'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Return the ref identifier unchanged in a call-argument context.

When a $ref is passed as a function argument (directly or nested inside a container argument via literalize_call()), V does not require .clone(); V passes the value automatically without copying.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Append .clone() to the ref identifier, except for scalars.

V’s container types (arrays, maps) are not copied by direct assignment, so a $ref marker appearing on the right-hand side of an emitted assignment must be cloned to satisfy the V compiler. V’s primitive scalars (int, bool, f64, …) have no .clone() method - int.clone() is a hard error - so we emit the bare identifier and let V’s automatic primitive copy do the right thing. When the caller did not supply ref_values we cannot tell which case applies and fall back to .clone(), which is correct for V’s original use case (map/array refs).

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

EPOCH seconds are routed through format_integer so a post-2038 value carries the i64(...) cast V requires for an integer literal outside signed 32-bit range (a bare 4085195400 is otherwise an out-of-range int literal), matching the i64 field type the RECORD strategy derives for it. In-range epoch seconds format identically to the plain integer, so every checked-in golden file stays byte-identical.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

Values in 32-bit signed range are formatted with the chosen integer format. Values outside that range but within 64-bit signed range use i64(...). Values outside 64-bit signed range use u64(...) (or raise for negative overflow).

property format_integer_widened: Callable[[int], str]

Always-i64(...)-cast integer formatter for widened collections (mixed-magnitude int sets/lists).

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config for the chosen strategy.

RECORD resolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member); INTERFACE wraps scalars in IVal(...); ERROR raises on unwrapped heterogeneous collections.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = 1
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE,)
indent: str = '\t'
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'unsafe { nil }'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'v'
record_struct_name_prefix: str = 'Record'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (V needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (V needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=False, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='[]IVal{}', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=<function make_narrowed_empty_form.<locals>._narrowed_empty_form>)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set='[]IVal{}', preamble_lines=(), set_opener_template='', supports_heterogeneity=False, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ('import math',)
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = True
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap V declaration + assignment in fn main().

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a V declaration in fn main().

class literalizer.languages.VisualBasic(*args: object, **kwargs: object)

Visual Basic (.NET) language specification.

VB.NET collection initializers (New T() { ... }, New HashSet(Of T) From { ... }, etc.) do not support comments inside the { ... } block. YAML comments associated with collection elements are therefore emitted as standalone comment lines before the collection — or before the variable declaration when a variable name is supplied.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

VisualBasic call style options.

NAMED = KeywordCallStyle(separator=':=')
POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

APOSTROPHE = CommentConfig(prefix="'", suffix='')
class DateFormats(*values)

Date format options for VisualBasic.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for VisualBasic.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

DIM = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = <function dict_format_factory.<locals>._build>
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Visual Basic.

ARRAY = 1
class SetFormats(*values)

Set type options for Visual Basic.

HASH_SET = <function set_format_factory.<locals>._build>
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Visual Basic.

DOTNET_6 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix="'", suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

default_dict_key_type: str = 'String'
default_dict_value_type: str = 'Object'
default_sequence_element_type: str = 'Object'
default_set_element_type: str = 'Object'
dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = <function dict_format_factory.<locals>._build>
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.vb'
false_literal: ClassVar[str] = 'False'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Format a VB.NET constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: Callable[[int], str]

Always-L-suffixed integer formatter for widened collections (mixed-magnitude int sets/lists).

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Format a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.PASCAL, IdentifierCase.CAMEL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'Nothing'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'vb.net'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (VisualBasic needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble.

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = 1
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = <function set_format_factory.<locals>._build>
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = False
supports_default_dict_key_type = True
supports_default_dict_value_type = True
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = True
supports_default_set_element_type = True
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'True'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap VB.NET declaration + assignment in separate Subs.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a VB.NET Dim declaration inside a Module.

When body_preamble carries call-stub declarations (Class and Function blocks plus their Dim ... As New ... instances) the stubs sit at module scope and content is placed inside Sub _calls(): VB rejects bare expression statements at module level, but shared subs taking no arguments are invoked by the fixture linter so the calls still execute.

class literalizer.languages.Wren(*args: object, **kwargs: object)

Wren language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Wren call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

BLOCK = CommentConfig(prefix='/*', suffix=' */')
SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for Wren.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DatetimeFormats(*values)

Datetime format options for Wren.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
class DeclarationStyles(*values)

Declaration style options.

VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = <class 'str'>
HEX = <function format_integer_hex>
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Wren.

LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Wren.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

NEWLINE = 1
class StringFormats(*values)

String format options.

DOUBLE = <function _build_backslash_formatter.<locals>._format>
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Wren.

V0_4 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Return the active call-style configuration.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.wren'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return a Wren ClassName.new constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = False
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = <class 'str'>
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 16
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'wren'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Wren needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Wren needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = True
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = False
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap declaration and assignment in a valid file (no-op).

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Yaml(*args: object, **kwargs: object)

YAML language specification.

Produces YAML flow-style values — flow mappings for dicts, and flow sequences for sequences and sets — so that the output is valid inline YAML that can be embedded in any YAML document.

Dates and datetimes are rendered as unquoted YAML native date / datetime literals, which YAML parsers interpret as typed values.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Yaml call style options.

class CommentFormats(*values)

Comment style options.

HASH = CommentConfig(prefix='#', suffix='')
class DateFormats(*values)

Date format options for Yaml.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
YAML = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
class DatetimeFormats(*values)

Datetime format options for Yaml.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
YAML = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
class DeclarationStyles(*values)

Declaration style options.

ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options — this language only supports raising.

ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
class IntegerFormats(*values)

Integer format options.

DECIMAL = 1
class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no JSON value-type variants.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for YAML.

SEQUENCE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for YAML.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for YAML.

V1_2 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style_config: ClassVar[PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle | CallSupport] = 'not_in_language'
call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.yaml'
false_literal: ClassVar[str] = 'false'
float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

static format_call_arg(_value: Value, formatted: str, /) str

Callable that rewrites a formatted direct call argument.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Default format_call_variable_assignment – reuse the literal-binding assignment formatter unchanged.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Default format_call_variable_declaration – reuse the literal-binding declaration formatter unchanged.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Format an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE,)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = 1
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

null_literal: ClassVar[str] = 'null'
numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

pygments_name = 'yaml'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (YAML needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (YAML needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ()
statement_terminator: ClassVar[str] = ''
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
static_preamble: ClassVar[Sequence[str]] = ()
string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = False
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = True
supports_no_variable_wrap_in_file = True
supports_non_string_dict_keys = True
supports_record_shape_names = False
supports_record_struct_name_prefix = False
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = True
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = False
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

true_literal: ClassVar[str] = 'true'
property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Default validate_spec_for_data — no spec/data constraints.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Unsupported: literalize() rejects BothVariableForms upstream.

static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap code in a valid file (no-op).

class literalizer.languages.Zig(*args: object, **kwargs: object)

Zig language specification.

class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Empty: this language has no alternative boolean formats.

class BytesFormats(*values)

Bytes formatting options.

BASE64 = <function format_bytes_base64>
HEX = <function format_bytes_hex>
class CallStyles(*values)

Zig call style options.

POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
class CommentFormats(*values)

Comment style options.

DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')
class DateFormats(*values)

Date format options for Zig.

ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)
ZIG = DateFormatConfig(formatter=<function _format_date_zig>, preamble_lines=(), type_produced=<class 'int'>)
class DatetimeFormats(*values)

Datetime format options for Zig.

EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)
ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)
ZIG = DatetimeFormatConfig(formatter=<function _format_datetime_zig>, preamble_lines=(), type_produced=<class 'int'>)
class DeclarationStyles(*values)

Declaration style options.

CONST = _ZigDeclarationStyleConfig(keyword='const', supports_redefinition=False)
VAR = _ZigDeclarationStyleConfig(keyword='var', supports_redefinition=True)
class DictEntryStyles(*values)

Dict entry style options.

DEFAULT = 1
class DictFormats(*values)

Dict/map format options.

DEFAULT = 1
class EmptyDictKey(*values)

Empty dict key options.

ALLOW = 1
class FloatFormats(*values)

Float format options.

FIXED = <function format_float_fixed>
REPR = <function format_float_repr>
SCIENTIFIC = <function format_float_scientific>
class HeterogeneousStrategies(*values)

Heterogeneous-scalar strategy options.

ERROR keeps the default ZVal union model (a record-shaped dict that mixes scalars with a container is rendered as a homogeneous-typed .{ .map = &.{ ... } }). RECORD instead renders each record-shaped dict (non-empty, string-keyed) as a generated const Record0 = struct { ... }; declared in the preamble plus a matching Record0{ .field = value, ... } literal whose fields are raw Zig values, so a field may mix scalars and containers that the homogeneous ZVal map cannot.

ERROR = 1
RECORD = 2
class IntegerFormats(*values)

Integer format options.

BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})
DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})
OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})
get_formatter(numeric_separator: Enum) Callable[[int], str]

Return the integer formatter for the given separator.

class JsonTypes(*values)

JSON value type options for Zig.

STD_JSON_VALUE = 'std.json.Value'

Zig’s standard library dynamic JSON value type.

class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

C++/Java/C#-style declaration modifiers: this language has none.

class NumericLiteralSuffixes(*values)

Numeric literal suffix options.

NONE = 1
class NumericSeparators(*values)

Numeric separator options.

NONE = 1
UNDERSCORE = 2
class NumericStyles(*values)

Numeric literal style options.

OVERLOADED = 1
class SequenceFormats(*values)

Sequence type options for Zig.

ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
class SetFormats(*values)

Set type options for Zig.

SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
class StatementTerminatorStyles(*values)

Statement terminator options.

SEMICOLON = 1
class StringFormats(*values)

String format options.

DOUBLE = 1
class TrailingCommas(*values)

Trailing comma options.

NO = TrailingCommaConfig(multiline_trailing_comma=False)
YES = TrailingCommaConfig(multiline_trailing_comma=True)
class VariableTypeHints(*values)

Variable type hint options.

NEVER = 1
SAFE = 2
class VersionFormats(*values)

Version options for Zig.

V0_12 = 1
allows_empty_call_parens = True
bool_formats

alias of BoolFormats

bytes_format: BytesFormats = <function format_bytes_hex>
bytes_formats

alias of BytesFormats

property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines for call rendering.

call_returns_expression = True
call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)
property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle

Configuration for the chosen call style.

call_styles

alias of CallStyles

property comment_config: CommentConfig

Configuration for the language’s comment syntax.

comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')
comment_formats

alias of CommentFormats

property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]

Compute body-preamble lines from the scalar map.

property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]

Predicate deciding whether a ref’s underlying value type inhibits the consume form.

Delegates to never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo ^ on register-trivial scalars) override this.

property data_dependent_preamble: Callable[[Value], tuple[str, ...]]

Return data-dependent preamble lines.

Under json_type the data rides inside a single JSON string, so no per-data preamble applies. Under RECORD this is the generated const Record0 = struct { ... }; block, emitted in dependency order so a nested record is declared before its parent.

date_format: DateFormats = DateFormatConfig(formatter=<function _format_date_zig>, preamble_lines=(), type_produced=<class 'int'>)
date_formats

alias of DateFormats

datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_zig>, preamble_lines=(), type_produced=<class 'int'>)
datetime_formats

alias of DatetimeFormats

declaration_style: DeclarationStyles = _ZigDeclarationStyleConfig(keyword='const', supports_redefinition=False)
declaration_styles

alias of DeclarationStyles

dict_entry_style: DictEntryStyles = 1
dict_entry_styles

alias of DictEntryStyles

dict_format: DictFormats = 1
property dict_format_config: DictFormatConfig

Configuration for dict formatting.

Under json_type dicts are rendered into the JSON text and the framework’s formatted output is discarded. Under RECORD every non-empty string-keyed dict is a record (rendered as a generated struct); the only plain dict that still reaches the dict formatter is the empty dict, emitted as the raw empty struct .{} instead of the ZVal .{ .map = &.{}} form.

dict_formats

alias of DictFormats

dict_supports_heterogeneous_values = True
element_separator: ClassVar[str] = ', '
empty_dict_keys

alias of EmptyDictKey

extension = '.zig'
property false_literal: str

The literal representing false.

Raw Zig false under RECORD (a bool field), the ZVal union literal otherwise.

float_format: FloatFormats = <function format_float_repr>
float_formats

alias of FloatFormats

property format_bytes: Callable[[bytes], str]

Callable that formats a bytes value as a string literal.

property format_call_arg: Callable[[Value, str], str]

Wrap each call argument in the ZVal union so call sites match the parameter shape emitted by _zig_call_preamble_stub().

Under json_type the argument is rendered as a std.json.Value produced by parseFromSlice instead.

property format_call_arg_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier in a call-argument context.

Delegates to format_call_ref_identifier. Override this to allow call-argument $ref values that would otherwise be rejected.

property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]

Format a $ref the caller authorized as consumable.

Delegates to format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++ std::move).

format_call_binding_body_preamble() tuple[str, ...]

Default format_call_binding_body_preamble – no extra body preamble lines for an inference-bound call result.

format_call_binding_file_pragmas() tuple[str, ...]

Default format_call_binding_file_pragmas – no file-level compiler-pragma line for an inference-bound call result.

property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return file-scope stubs for a call expression.

Under json_type call arguments are std.json.Value expressions rather than ZVal union literals, so the stub accepts anytype parameters just as the RECORD strategy does.

property format_call_ref_identifier: Callable[[str, Value | None], str]

Rewrite a {"$ref": "name"} identifier into the language’s call expression syntax.

property format_call_statement: Callable[[str], str]

Return call-statement formatting for this language.

property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]

Return stub declarations for a call expression.

Zig disallows nested function declarations inside main, so every stub is emitted at file scope via format_call_preamble_stub instead.

property format_call_target: Callable[[Sequence[str]], str]

Rewrite a dotted call target into the language’s call syntax.

property format_call_variable_assignment: Callable[[str, str, Value], str]

Callable that formats an assignment binding a call result.

The call-expression counterpart of format_call_variable_declaration; the ZVal tagging a literal-binding assignment applies is dropped since a call result is not a ZVal union literal.

property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a declaration binding a call result.

A Zig literal binding wraps the right-hand side in a designated-initializer ZVal projection (.{ .int = 42 }), or a generated Record0{ .field = value, ... } struct literal under the RECORD strategy, and declares an explicit value type (: ZVal). A call’s return type is opaque to the renderer and is neither, so the call result is bound with a plain inferred declaration (const my_data = make_widget(...); / var my_data = make_widget(...);): the Zig const/var type inference means no caller-supplied return-type hint is needed, and the value-wrapping and : ZVal annotation are dropped.

static format_constructor_target(class_name: str, /) str

Return class_name as a zero-argument constructor call target.

property format_date: Callable[[date], str]

Callable that formats a date as a string literal.

property format_datetime: Callable[[datetime], str]

Callable that formats a datetime as a string literal.

property format_float: Callable[[float], str]

Callable that formats a float value as a literal.

property format_integer: Callable[[int], str]

Callable that formats an int value as a literal.

property format_integer_widened: None

Default format_integer_widened – no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.

property format_ordered_map_entry: Callable[[str, Value, str], str]

Callable that formats one ordered-map entry.

property format_sequence_entry: Callable[[Value, str], str]

Format a sequence entry.

property format_set_entry: Callable[[Value, str], str]

Format a set entry.

property format_string: Callable[[str], str]

Callable that formats a string value as a quoted literal.

property format_time: Callable[[time], str]

Callable that formats a time as a string literal.

property format_variable_assignment: Callable[[str, str, Value], str]

Format an assignment to an existing variable.

property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]

Callable that formats a new variable declaration.

Under json_type the declaration is a parseFromSlice call. A const binding is emitted with an inferred type; a var binding gets an explicit : std.json.Value annotation so a subsequent assignment can compile against the same static type.

Otherwise this closes over the chosen date/datetime type_produced so the ZVal tag selection can be driven by the parsed Value rather than the rendered text.

has_free_function_calls = True
property heterogeneous_behavior: HeterogeneousBehavior

Return the heterogeneous-behavior config.

Under json_type heterogeneous scalars all flow through the JSON text, so scalar-uniformity checks are skipped. RECORD resolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member); ERROR keeps the default ZVal model.

heterogeneous_strategies

alias of HeterogeneousStrategies

heterogeneous_strategy: HeterogeneousStrategies = 1
identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL, IdentifierCase.CAMEL)
indent: str = '    '
indent_closing_delimiter: ClassVar[bool] = False
integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})
integer_formats

alias of IntegerFormats

integer_width_strategies

alias of BareIntegerWidthStrategies

integer_width_strategy: BareIntegerWidthStrategies = 1
json_type: JsonTypes | None = None
json_types

alias of JsonTypes

language_version: VersionFormats = 1
property leading_preamble: LeadingPreamble

Default leading_preamble – no preamble lines that must precede Language.static_preamble.

max_call_parameters = 9223372036854775807
modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()
modifiers

alias of Modifiers

property null_literal: str

The literal representing null.

The default ZVal model uses the union tag .nil; under RECORD a null record field is a raw Zig null (its field type is the optional ?i64).

numeric_literal_suffix: NumericLiteralSuffixes = 1
numeric_literal_suffixes

alias of NumericLiteralSuffixes

numeric_separator: NumericSeparators = 1
numeric_separators

alias of NumericSeparators

numeric_style: NumericStyles = 1
numeric_styles

alias of NumericStyles

property ordered_map_format_config: OrderedMapFormatConfig

Configuration for ordered-map formatting.

Under json_type ordered maps are folded into the JSON text. An ordered map is never record-eligible, so under RECORD it stays a map but as a raw &.{ .{ .key = ..., .val = ... }, ... } slice of key/val struct values rather than the ZVal .{ .map = &.{ ... }} form.

pygments_name = 'zig'
record_struct_name_prefix: str = 'Record'
reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})
property scalar_body_preamble: dict[type, tuple[str, ...]]

Per-instance scalar body preamble (Zig needs none).

property scalar_preamble: dict[type, tuple[str, ...]]

Per-instance scalar preamble (Zig needs none).

sequence_binding_declarations(declarations: tuple[str, ...]) str

Default sequence_binding_declarations – join the per-binding snippets with newlines.

sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)
property sequence_format_config: SequenceFormatConfig

Configuration for the chosen sequence format.

Under json_type lists are rendered into the JSON text and the framework’s formatted output is discarded. Under RECORD a list is a raw Zig literal – a &.{ ... } slice (homogeneous / empty) or a .{ ... } tuple (heterogeneous), both closed by a single } rather than the ZVal .{ .arr = &.{ ... }} form. Only the closer changes here; the opener is chosen per list by sequence_open.

sequence_formats

alias of SequenceFormats

property sequence_open: Callable[[list[Value]], str]

Callable that returns the opening delimiter for a sequence.

Under RECORD a homogeneous or empty list opens &.{ so the literal coerces to a []const T slice; a heterogeneous list opens .{ so it is a Zig tuple (matching the struct { T0, ... } field type _zig_value_type() derives). Every other strategy keeps the ZVal array opener.

set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)
property set_format_config: SetFormatConfig

Configuration for the chosen set format.

set_formats

alias of SetFormats

skip_null_dict_values: ClassVar[bool] = False
special_float_preamble: ClassVar[tuple[str, ...]] = ('const std = @import("std");',)
statement_terminator: ClassVar[str] = ';'
statement_terminator_style: StatementTerminatorStyles = 1
statement_terminator_styles

alias of StatementTerminatorStyles

static_body_preamble: ClassVar[Sequence[str]] = ()
property static_preamble: Sequence[str]

File-scope preamble.

Under json_type only const std = @import("std"); is emitted (the data flows through std.json.parseFromSlice). The default ZVal model needs its tagged-union declaration; the RECORD strategy emits raw Zig values and generated struct declarations instead, so it needs no static preamble.

string_format: StringFormats = 1
string_formats

alias of StringFormats

supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})
supports_call_style = True
supports_collection_comments: ClassVar[bool] = True
supports_default_dict_key_type = False
supports_default_dict_value_type = False
supports_default_ordered_map_value_type = False
supports_default_sequence_element_type = False
supports_default_set_element_type = False
supports_dict_literal_as_free_expression = True
supports_dotted_call_stub = True
supports_dotted_calls = True
supports_empty_dict_key = False
supports_inline_multiline_dict_args = True
supports_module_name = False
supports_multi_param_call_wrapper_stub = False
supports_no_variable_wrap_in_file = False
supports_non_string_dict_keys = False
supports_record_shape_names = False
supports_record_struct_name_prefix = True
supports_scalar_before_comments: ClassVar[bool] = True
supports_scalar_inline_comments: ClassVar[bool] = False
supports_special_floats = True
supports_standalone_comments_in_wrapped_calls = True
supports_variable_names = True
supports_zero_parameter_calls = True
trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)
property trailing_comma_config: TrailingCommaConfig

Configuration for trailing-comma behavior.

trailing_commas

alias of TrailingCommas

property true_literal: str

The literal representing true.

Raw Zig true under RECORD (a bool field), the ZVal union literal otherwise.

property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]

Return preamble lines for empty-collection type hints.

property validate_call_arg: Callable[[Value], None]

Return call-argument validation for this language.

validate_spec_for_data(data: Value) None

Raise if the spec cannot produce valid code for data.

When json_type is active, walk data to reject non-string dict keys, which JSON objects cannot represent.

variable_type_hints: VariableTypeHints = 1
variable_type_hints_formats

alias of VariableTypeHints

version_formats

alias of VersionFormats

wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str

Default wrap_calls_with_declarations — concatenate the declarations and calls and route through wrap_in_file() in call mode.

wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap Zig declaration + assignment in a main function.

wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str

Wrap a Zig declaration in a main function.