Type Hint Support


The Amplify SDK defines type hints for all functions, methods, and attributes. This feature allows IDEs such as Visual Studio Code and Google Colaboratory to detect code errors through code completion and type checking.


If using Visual Studio Code, install the Python extension and add the following settings to enable code completion and type checking.


    "python.languageServer": "Pylance",
    "python.analysis.typeCheckingMode": "basic",


Depending on the method or function you call, the type or array dimension may not always be deterministic.

For example, the amplify.einsum() function returns Poly or PolyArray depending on the value of its argument, which may not be deterministic, resulting in an error or warning from the type checker. In such cases, you can avoid the error by specifying the type explicitly, as follows.

from amplify import Poly, einsum

# The argument "ij,ki,kj->" is expected to return a poly (scalar), but the type checker cannot determine it.
objective: Poly = einsum("ij,ki,kj->", d, q1, q2)  # type: ignore