Skip to content

FutureStatement

A future statement that imports features from future.

Future statements are directives to the compiler that a particular module should be compiled using syntax or semantics from a future Python release. They must appear near the top of the module, after the module docstring (if any).

Use this in the futureImports prop of SourceFile to ensure proper placement.

import { FutureStatement } from "@alloy-js/python";
<FutureStatement feature="string" />
featurestring

The name of the feature to import from future.

<SourceFile path="models.py" futureImports={<FutureStatement feature="annotations" />}>
<ClassDeclaration name="User">
<PropertyDeclaration name="manager" type="User" />
</ClassDeclaration>
</SourceFile>

renders to

from __future__ import annotations
class User:
manager: User