Signature¶
A collection of signature components that define a function’s parameters and return type.
Declaration
struct Signature
Discussion
Use the static functions to create a new Signature and then call its instance functions to extend it:
Method(
name: "my_function",
signature: {
.positionalOrKeyword("string", annotation: interpreter.builtins.str)
.positionalOrKeyword("flag", annotation: interpreter.builtins.bool, default: false)
.returns(interpreter.builtins.None)
},
body: my_function
)
Properties
The list of signature components.
Static Properties
Returns a signature with no arguments and no return type.
Functions
Appends a keyword-only parameter to the signature.
Appends a positional-only parameter to the signature.
Appends a positional-or-keyword parameter to the signature.
Appends a return value with the given annotation to the signature.
Appends a variable keyword parameter to the signature.
Appends a variable positional parameter to the signature.
Static Functions
Creates a signature with a keyword-only parameter.
Creates a signature with a positional-only parameter.
Creates a signature with a positional-or-keyword parameter.
Creates a signature that returns a value with the given annotation.
Creates a signature with a variable keyword parameter.
Creates a signature with a variable positional parameter.
Conforms to
Sequence