Annotations — SIP v6.7.1 Documentation

# Annotations

In this section we describe each of the annotations that can be used in specification files.

Annotations can either be argument annotations, class annotations, mapped type annotations, enum annotations, exception annotations, function annotations, typedef annotations or variable annotations depending on the context in which they can be used.

Annotations are placed between forward slashes (`/`). Multiple annotations are comma separated within the slashes.

Annotations have a type and, possibly, a value. The type determines the format of the value. The name of an annotation and its value are separated by `=`.

Annotations can have one of the following types:

boolean

  This type of annotation has no value and is implicitly true.

integer

  This type of annotation is an integer. In some cases the value is optional.

name

  The value is a name that is compatible with a C/C++ identifier. In some cases the value is optional.

dotted name

  The value is a name that is compatible with an identifier preceded by a Python scope.

string

  The value is a double quoted string.

The following example shows argument and function annotations:

    void exec(QWidget * /Transfer/) /ReleaseGIL/;

## Argument Annotations

AllowNone

  This boolean annotation specifies that the value of the corresponding argument (which should be either `SIP_PYBUFFER`, `SIP_PYCALLABLE`, `SIP_PYDICT`, `SIP_PYLIST`, `SIP_PYSLICE`, `SIP_PYTUPLE` or `SIP_PYTYPE`) may be `None`.

Array

  This boolean annotation specifies that the corresponding argument refers to an array.

  The argument should be either a pointer to a wrapped type, a `char *` or a `unsigned char *`. If the argument is a character array then the annotation also implies the `Encoding` annotation with an encoding of `"None"`.

  There must be a corresponding argument with the `ArraySize` annotation specified. The annotation may only be specified once in a list of arguments.

ArraySize

  This boolean annotation specifies that the corresponding argument (which should be either `short`, `unsigned short`, `int`, `unsigned`, `long` or `unsigned long`) refers to the size of an array. There must be a corresponding argument with the `Array` annotation specified. The annotation may only be specified once in a list of arguments.

Constrained

  Python will automatically convert between certain compatible types. For example, if a floating pointer number is expected and an integer supplied, then the integer will be converted appropriately. This can cause problems when wrapping C or C++ functions with similar signatures. For example:

      // The wrapper for this function will also accept an integer argument
      // which Python will automatically convert to a floating point number.
      void foo(double);

      // The wrapper for this function will never get used.
      void foo(int);

  This boolean annotation specifies that the corresponding argument (which should be either `bool`, `int`, `float`, `double`, `enum` or a wrapped class) must match the type without any automatic conversions. In the context of a wrapped class the invocation of any `%ConvertToTypeCode` is suppressed.

  The following example gets around the above problem:

      // The wrapper for this function will only accept floating point
      // numbers.
      void foo(double /Constrained/);

      // The wrapper for this function will be used for anything that Python
      // can convert to an integer, except for floating point numbers.
      void foo(int);

  Any type hint for the argument will be ignored.

DisallowNone

  This boolean annotation specifies that the value of the corresponding argument (which should be a pointer to either a C++ class or a mapped type) must not be `None`.

Encoding

  This string annotation specifies that the corresponding argument (which should be either `char`, `const char`, `char *` or `const char *`) refers to an encoded character or `'\0'` terminated encoded string with the specified encoding. The encoding can be either `"ASCII"`, `"Latin-1"`, `"UTF-8"` or `"None"`. An encoding of `"None"` means that the corresponding argument refers to an unencoded character or string.

  The default encoding is specified by the `%DefaultEncoding` directive. If the directive is not specified then `None` is used.

  The `bytes` type is used to represent the argument if the encoding is `"None"` and the `str` type otherwise.

GetWrapper

  This boolean annotation is only ever used in conjunction with handwritten code specified with the `%MethodCode` directive. It causes an extra variable to be generated for the corresponding argument which is a pointer to the Python object that wraps the argument.

  See the `%MethodCode` directive for more detail.

In

  This boolean annotation is used to specify that the corresponding argument (which should be a pointer type) is used to pass a value to the function.

  For pointers to wrapped C structures or C++ class instances, `char *` and `unsigned char *` then this annotation is assumed unless the `Out` annotation is specified.

  For pointers to other types then this annotation must be explicitly specified if required. The argument will be dereferenced to obtain the actual value.

  Both `In` and `Out` may be specified for the same argument.

KeepReference

  This optional integer annotation is used to specify that a reference to the corresponding argument should be kept to ensure that the object is not garbage collected. If the method is called again with a new argument then the reference to the previous argument is discarded. Note that ownership of the argument is not changed.

  If the function is a method then the reference is kept by the instance, i.e. `self`. Therefore the extra reference is released when the instance is garbage collected.

  If the function is a class method or an ordinary function and it is annotated using the `Factory` annotation, then the reference is kept by the object created by the function. Therefore the extra reference is released when that object is garbage collected.

  Otherwise the reference is not kept by any specific object and will never be released.

  If a value is specified then it defines the argument’s key. Arguments of different constructors or methods that have the same key are assumed to refer to the same value.

NoCopy

  This boolean annotation is used with arguments of virtual methods that are a `const` reference to a class. Normally, if the class defines a copy constructor then a copy of the returned reference is automatically created and wrapped before being passed to a Python reimplementation of the method. The copy will be owned by Python. This means that the reimplementation may take a reference to the argument without having to make an explicit copy.

  If the annotation is specified then the copy is not made and the original reference is wrapped instead and will be owned by C++.

Out

  This boolean annotation is used to specify that the corresponding argument (which should be a pointer type) is used by the function to return a value as an element of a tuple.

  For pointers to wrapped C structures or C++ class instances, `char *` and `unsigned char *` then this annotation must be explicitly specified if required.

  For pointers to other types then this annotation is assumed unless the `In` annotation is specified.

  Both `In` and `Out` may be specified for the same argument.

PyInt

  This boolean annotation is used with `char`, `signed char` and `unsigned char` arguments to specify that they should be interpreted as integers rather than strings of one character.

ResultSize

  This boolean annotation is used with functions or methods that return a `void *` or `const void *`. It identifies an argument that defines the size of the block of memory whose address is being returned. This allows the `sip.voidptr` object that wraps the address to support the Python buffer protocol.

ScopesStripped

  This integer annotation is only used with Qt signal arguments. Normally the fully scoped type of the argument is used but this annotation specifies that the given number of scopes should be removed.

Transfer

  This boolean annotation is used to specify that ownership of the corresponding argument (which should be a wrapped C structure or C++ class instance) is transferred from Python to C++. In addition, if the argument is of a class method, then it is associated with the class instance with regard to the cyclic garbage collector.

  If the annotation is used with the `Array` annotation then the array of pointers to the sequence of C structures or C++ class instances that is created on the heap is not automatically freed.

  See Ownership of Objects for more detail.

TransferBack

  This boolean annotation is used to specify that ownership of the corresponding argument (which should be a wrapped C structure or C++ class instance) is transferred back to Python from C++. In addition, any association of the argument with regard to the cyclic garbage collector with another instance is removed.

  See Ownership of Objects for more detail.

TransferThis

  This boolean annotation is only used in C++ constructors or methods. In the context of a constructor or factory method it specifies that ownership of the instance being created is transferred from Python to C++ if the corresponding argument (which should be a wrapped C structure or C++ class instance) is not `None`. In addition, the newly created instance is associated with the argument with regard to the cyclic garbage collector.

  In the context of a non-factory method it specifies that ownership of `this` is transferred from Python to C++ if the corresponding argument is not `None`. If it is `None` then ownership is transferred to Python.

  The annotation may be used more that once, in which case ownership is transferred to last instance that is not `None`.

  See Ownership of Objects for more detail.

TypeHint

  This string annotation specifies the type of the argument as it will appear in any generated docstrings and PEP 484 type hints. It is the equivalent of specifying `TypeHintIn` and `TypeHintOut` with the same value. It is usually used with arguments of type `SIP_PYOBJECT` to provide a more specific type.

TypeHintIn

  This string annotation specifies the type of the argument as it will appear in any generated docstrings and PEP 484 type hints when the argument is used to pass a value to a function (rather than being used to return a value from a function). It is usually used with arguments of type `SIP_PYOBJECT` to provide a more specific type.

TypeHintOut

  This string annotation specifies the type of the argument as it will appear in any generated docstrings and PEP 484 type hints when the argument is used to return a value from a function (rather than being used to pass a value to a function). It is usually used with arguments of type `SIP_PYOBJECT` to provide a more specific type.

TypeHintValue

  This string annotation specifies the default value of the argument as it will appear in any generated docstrings.

## Class Annotations

Abstract

  This boolean annotation is used to specify that the class has additional pure virtual methods that have not been specified and so it cannot be instantiated or sub-classed from Python. It should not be specified if all pure virtual methods have been specified.

AllowNone

  Normally when a Python object is converted to a C/C++ instance `None` is handled automatically before the class’s `%ConvertToTypeCode` is called. This boolean annotation specifies that the handling of `None` will be left to the `%ConvertToTypeCode`. The annotation is ignored if the class does not have any `%ConvertToTypeCode`.

DelayDtor

  This boolean annotation is used to specify that the class’s destructor should not be called until the Python interpreter exits. It would normally only be applied to singleton classes.

  When the Python interpreter exits the order in which any wrapped instances are garbage collected is unpredictable. However, the underlying C or C++ instances may need to be destroyed in a certain order. If this annotation is specified then when the wrapped instance is garbage collected the C or C++ instance is not destroyed but instead added to a list of delayed instances. When the interpreter exits then the function `sipDelayedDtors()` is called with the list of delayed instances. `sipDelayedDtors()` can then choose to call (or ignore) the destructors in any desired order.

  The `sipDelayedDtors()` function must be specified using the `%ModuleCode` directive.

void sipDelayedDtors(const sipDelayedDtor *dd_list)
  Parameters

    - dd_list – the linked list of delayed instances.

type sipDelayedDtor

  This structure describes a particular delayed destructor.

  const char *dd_name

    This is the name of the class excluding any package or module name.

  void *dd_ptr

    This is the address of the C or C++ instance to be destroyed. It’s exact type depends on the value of `dd_isderived`.

  int dd_isderived

    This is non-zero if the type of `dd_ptr` is actually the generated derived class. This allows the correct destructor to be called. See Generated Derived Classes.

  sipDelayedDtor *dd_next

    This is the address of the next entry in the list or zero if this is the last one.

  Note that the above applies only to C and C++ instances that are owned by Python.

Deprecated

  This boolean annotation is used to specify that the class is deprecated. It is the equivalent of annotating all the class’s constructors, function and methods as being deprecated.

FileExtension

  This string annotation is used to specify the filename extension to be used for the file containing the generated code for this class.

ExportDerived

  In many cases SIP generates a derived class for each class being wrapped (see Generated Derived Classes). Normally this is used internally. This boolean annotation specifies that the declaration of the class is exported and able to be used by handwritten code.

External

  This boolean annotation is used to specify that the class is defined in another module. Declarations of external classes are private to the module in which they appear.

Metatype

  This dotted name annotation specifies the name of the Python type object (i.e. the value of the `tp_name` field) used as the meta-type used when creating the type object for this C structure or C++ type.

  See the section Types and Meta-types for more details.

Mixin

  This boolean annotation specifies that the class can be used as a mixin with other wrapped classes.

  Normally a Python application cannot define a new class that is derived from more than one wrapped class. In C++ this would create a new C++ class. This cannot be done from Python. At best a C++ instance of each of the wrapped classes can be created and wrapped as separate Python objects. However some C++ classes may function perfectly well with this restriction. Such classes are often intended to be used as mixins.

  If this annotation is specified then a separate instance of the class is created. The main instance automatically delegates to the instance of the mixin when required. A mixin class should have the following characteristics:

  - Any constructor arguments should be able to be specified using keyword arguments.

  - The class should not have any virtual methods.

NoDefaultCtors

  This boolean annotation is used to suppress the automatic generation of default constructors for the class.

NoTypeHint

  This boolean annotation is used to suppress the generation of the PEP 484 type hint for the class and its contents.

PyName

  This name annotation specifies an alternative name for the class being wrapped which is used when it is referred to from Python.

  See also

  `%AutoPyName`

Supertype

  This dotted name annotation specifies the name of the Python type object (i.e. the value of the `tp_name` field) used as the super-type used when creating the type object for this C structure or C++ type.

  See the section Types and Meta-types for more details.

TypeHint

  This string annotation specifies the type of the class as it will appear in any generated docstrings and PEP 484 type hints. It is the equivalent of specifying `TypeHintIn` and `TypeHintOut` with the same value.

TypeHintIn

  This string annotation specifies the type of the class as it will appear in any generated docstrings and PEP 484 type hints when an instance of the class is passed as an argument to a function (rather than being returned from a function). It is usually used with classes that implement `%ConvertToTypeCode` to allow additional types to be used whenever an instance of the class is expected.

TypeHintOut

  This string annotation specifies the type of the class as it will appear in any generated docstrings and PEP 484 type hints when an instance of the class is returned from a function (rather than being used to pass a value to a function).

TypeHintValue

  This string annotation specifies the default value of the class as it will appear in any generated docstrings.

VirtualErrorHandler

  This name annotation specifies the handler (defined by the `%VirtualErrorHandler` directive) that is called when a Python re-implementation of any of the class’s virtual C++ functions raises a Python exception. If not specified then the handler specified by the `default_VirtualErrorHandler` argument of the `%Module` directive is used.

  See also

  `NoVirtualErrorHandler`, `VirtualErrorHandler`, `%VirtualErrorHandler`

## Mapped Type Annotations

AllowNone

  Normally when a Python object is converted to a C/C++ instance `None` is handled automatically before the mapped type’s `%ConvertToTypeCode` is called. This boolean annotation specifies that the handling of `None` will be left to the `%ConvertToTypeCode`.

NoAssignmentOperator

  This boolean annotation is used to specify that the C++ type does not have a public assignment operator.

NoCopyCtor

  This boolean annotation is used to specify that the C++ type does not have a public copy constructor.

NoDefaultCtor

  This boolean annotation is used to specify that the C++ type does not have a public default constructor.

NoRelease

  This boolean annotation is used to specify that the mapped type does not support the `sipReleaseType()` function. Any `%ConvertToTypeCode` should not create temporary instances of the mapped type, i.e. it should not return `SIP_TEMPORARY`.

PyName

  This name annotation specifies an alternative name for the mapped type being wrapped which is used when it is referred to from Python. The only time a Python type is created for a mapped type is when it is used as a scope for static methods or enums.

  It should not be used with mapped type templates.

  See also

  `%AutoPyName`

TypeHint

  This string annotation specifies the type of the mapped type as it will appear in any generated docstrings and PEP 484 type hints. It is the equivalent of specifying `TypeHintIn` and `TypeHintOut` with the same value.

TypeHintIn

  This string annotation specifies the type of the mapped type as it will appear in any generated docstrings and PEP 484 type hints when it is passed to a function (rather than being returned from a function).

TypeHintOut

  This string annotation specifies the type of the mapped type as it will appear in any generated docstrings and PEP 484 type hints when it is returned from a function (rather than being passed to a function).

TypeHintValue

  This string annotation specifies the default value of the mapped type as it will appear in any generated docstrings.

## Enum Annotations

BaseType

  This name annotation specifies the type from the `enum` module that will be used as the base type of the enum. The possible values are `Enum` (corresponding to `Enum`), `Flag` (corresponding to `Flag`), `IntEnum` (corresponding to `IntEnum`), `UIntEnum` (also corresponding to `IntEnum` but with unsigned members) and `IntFlag` (corresponding to `IntFlag`). The default value is `Enum`. The members of `Flag` and `IntFlag` enums are implicitly unsigned.

  This annotation is only available when ABI v13 or later is specified.

NoScope

  This boolean annotation specifies the that scope of an enum’s members should be omitted in the generated code. Normally this would mean that the generated code will not compile. However it is useful when defining pseudo-enums, for example, to wrap global values so that they are defined (in Python) within the scope of a class.

NoTypeHint

  This boolean annotation is used to suppress the generation of the PEP 484 type hint for the enum or enum member.

PyName

  This name annotation specifies an alternative name for the enum or enum member being wrapped which is used when it is referred to from Python.

  See also

  `%AutoPyName`

## Exception Annotations

Default

  This boolean annotation specifies that the exception being defined will be used as the default exception to be caught if a function or constructor does not have a `throw` clause.

  This annotaion is ignored when using ABI v13.1 or later and v12.9 or later.

PyName

  This name annotation specifies an alternative name for the exception being defined which is used when it is referred to from Python.

  See also

  `%AutoPyName`

## Function Annotations

AbortOnException

  This boolean annotation specifies that when a Python re-implementation of a virtual C++ function raises a Python exception then `abort()` is called after the error handler returns.

AllowNone

  This boolean annotation is used to specify that the value returned by the function (which should be either `SIP_PYBUFFER`, `SIP_PYCALLABLE`, `SIP_PYDICT`, `SIP_PYLIST`, `SIP_PYSLICE`, `SIP_PYTUPLE` or `SIP_PYTYPE`) may be `None`.

AutoGen

  This optional name annotation is used with class methods to specify that the method be automatically included in all sub-classes. The value is the name of a feature (specified using the `%Feature` directive) which must be enabled for the method to be generated.

Default

  This boolean annotation is only used with C++ constructors. Sometimes SIP needs to create a class instance. By default it uses a constructor with no compulsory arguments if one is specified. (SIP will automatically generate a constructor with no arguments if no constructors are specified.) This annotation is used to explicitly specify which constructor to use. Zero is passed as the value of any arguments to the constructor. This annotation is ignored if the class defines `%InstanceCode`.

Deprecated

  This boolean annotation is used to specify that the constructor or function is deprecated. A deprecation warning is issued whenever the constructor or function is called.

DisallowNone

  This boolean annotation is used to specify that the value returned by the function (which should be a pointer to either a C++ class or a mapped type) must not be `None`.

Encoding

  This string annotation serves the same purpose as the `Encoding` argument annotation when applied to the type of the value returned by the function.

Factory

  This boolean annotation specifies that the value returned by the function (which should be a wrapped C structure or C++ class instance) is a newly created instance and is owned by Python.

  See Ownership of Objects for more detail.

HoldGIL

  This boolean annotation specifies that the Python Global Interpreter Lock (GIL) is not released before the call to the underlying C or C++ function. See The Python Global Interpreter Lock and the `ReleaseGIL` annotation.

__imatmul__

  This boolean annotation specifies that a `__imatmul__()` method should be automatically generated that will use the method being annotated to compute the value that the `__imatmul__()` method will return.

KeepReference

  This optional integer annotation serves the same purpose as the `KeepReference` argument annotation when applied to the type of the value returned by the function.

  If the function is a class method or an ordinary function then the reference is not kept by any other object and so the returned value will never be garbage collected.

KeywordArgs

  This string annotation specifies the level of support the argument parser generated for this function will provide for passing the parameters using Python’s keyword argument syntax. The value of the annotation can be either `"None"` meaning that keyword arguments are not supported, `"All"` meaning that all named arguments can be passed as keyword arguments, or `"Optional"` meaning that all named optional arguments (i.e. those with a default value) can be passed as keyword arguments.

  If the annotation is not used then the value specified by the `keyword_arguments` argument of the `%Module` directive is used.

  Keyword arguments cannot be used for functions that use an ellipsis to designate that the function has a variable number of arguments.

__len__

  This boolean annotation specifies that a `__len__()` method should be automatically generated that will use the method being annotated to compute the value that the `__len__()` method will return.

__matmul__

  This boolean annotation specifies that a `__matmul__()` method should be automatically generated that will use the method being annotated to compute the value that the `__matmul__()` method will return.

NewThread

  This boolean annotation specifies that the function (which must be a virtual) will be executed in a new thread.

NoArgParser

  This boolean annotation is used with methods and global functions to specify that the supplied `%MethodCode` will handle the parsing of the arguments.

NoCopy

  This boolean annotation is used with methods and global functions that return a `const` reference to a class. Normally, if the class defines a copy constructor then a copy of the returned reference is automatically created and wrapped. The copy will be owned by Python.

  If the annotation is specified then the copy is not made and the original reference is wrapped instead and will be owned by C++.

NoDerived

  This boolean annotation is only used with C++ constructors. In many cases SIP generates a derived class for each class being wrapped (see Generated Derived Classes). This derived class contains constructors with the same C++ signatures as the class being wrapped. Sometimes you may want to define a Python constructor that has no corresponding C++ constructor. This annotation is used to suppress the generation of the constructor in the derived class.

NoRaisesPyException

  This boolean annotation specifies that the function or constructor does not raise a Python exception to indicate that an error occurred.

  See also

  `RaisesPyException`

NoTypeHint

  This boolean annotation is used to suppress the generation of the PEP 484 type hint for the function or constructor.

NoVirtualErrorHandler

  This boolean annotation specifies that when a Python re-implementation of a virtual C++ function raises a Python exception then `PyErr_Print()` is always called. Any error handler specified by either the `VirtualErrorHandler` function annotation, the `VirtualErrorHandler` class annotation or the `default_VirtualErrorHandler` argument of the `%Module` directive is ignored.

  See also

  `VirtualErrorHandler`, `VirtualErrorHandler`, `%VirtualErrorHandler`

Numeric

  This boolean annotation specifies that the operator should be interpreted as a numeric operator rather than a sequence operator.

  Python uses the `+` operator for adding numbers and concatanating sequences, and the `*` operator for multiplying numbers and repeating sequences. Unless this or the `Sequence` annotation is specified, SIP tries to work out which is meant by looking at other operators that have been defined for the type. If it finds either `-`, `-=`, `/`, `/=`, `%` or `%=` defined then it assumes that `+`, `+=`, `*` and `*=` should be numeric operators. Otherwise, if it finds either `[]`, `__getitem__()`, `__setitem__()` or `__delitem__()` defined then it assumes that they should be sequence operators.

PostHook

  This name annotation is used to specify the name of a Python builtin that is called immediately after the call to the underlying C or C++ function or any handwritten code. The builtin is not called if an error occurred. It is primarily used to integrate with debuggers.

PreHook

  This name annotation is used to specify the name of a Python builtin that is called immediately after the function’s arguments have been successfully parsed and before the call to the underlying C or C++ function or any handwritten code. It is primarily used to integrate with debuggers.

PyName

  This name annotation specifies an alternative name for the function being wrapped which is used when it is referred to from Python.

  See also

  `%AutoPyName`

PyInt

  This boolean annotation serves the same purpose as the `PyInt` argument annotation when applied to the type of the value returned by the function.

RaisesPyException

  This boolean annotation specifies that the function or constructor raises a Python exception to indicate that an error occurred. Any current exception is cleared before the function or constructor is called. It is ignored if the `%MethodCode` directive is used.

  See also

  `NoRaisesPyException`

ReleaseGIL

  This boolean annotation specifies that the Python Global Interpreter Lock (GIL) is released before the call to the underlying C or C++ function and reacquired afterwards. It should be used for functions that might block or take a significant amount of time to execute. See The Python Global Interpreter Lock and the `HoldGIL` annotation.

Sequence

  This boolean annotation specifies that the operator should be interpreted as a sequence operator rather than a numeric operator.

  Python uses the `+` operator for adding numbers and concatanating sequences, and the `*` operator for multiplying numbers and repeating sequences. Unless this or the `Numeric` annotation is specified, SIP tries to work out which is meant by looking at other operators that have been defined for the type. If it finds either `-`, `-=`, `/`, `/=`, `%` or `%=` defined then it assumes that `+`, `+=`, `*` and `*=` should be numeric operators. Otherwise, if it finds either `[]`, `__getitem__()`, `__setitem__()` or `__delitem__()` defined then it assumes that they should be sequence operators.

Transfer

  This boolean annotation specifies that ownership of the value returned by the function (which should be a wrapped C structure or C++ class instance) is transferred to C++. It is only used in the context of a class constructor or a method.

  In the case of methods returned values (unless they are new references to already wrapped values) are normally owned by C++ anyway. However, in addition, an association between the returned value and the instance containing the method is created with regard to the cyclic garbage collector.

  See Ownership of Objects for more detail.

TransferBack

  This boolean annotation specifies that ownership of the value returned by the function (which should be a wrapped C structure or C++ class instance) is transferred back to Python from C++. Normally returned values (unless they are new references to already wrapped values) are owned by C++. In addition, any association of the returned value with regard to the cyclic garbage collector with another instance is removed.

  See Ownership of Objects for more detail.

TransferThis

  This boolean annotation specifies that ownership of `this` is transferred from Python to C++.

  See Ownership of Objects for more detail.

TypeHint

  This string annotation specifies the type of the value returned by the function as it will appear in any generated docstrings and PEP 484 type hints. It is usually used with results of type `SIP_PYOBJECT` to provide a more specific type.

VirtualErrorHandler

  This name annotation specifies the handler (defined by the `%VirtualErrorHandler` directive) that is called when a Python re-implementation of the virtual C++ function raises a Python exception. If not specified then the handler specified by the class’s `VirtualErrorHandler` is used.

  See also

  `NoVirtualErrorHandler`, `VirtualErrorHandler`, `%VirtualErrorHandler`

## Typedef Annotations

Capsule

  This boolean annotation may only be used when the base type is `void *` and specifies that a Python capsule object is used to wrap the value rather than a `sip.voidptr`. The advantage of using a capsule is that name based type checking is performed using the name of the type being defined.

  For versions of Python that do not support capules `sip.voidptr` is used instead and name based type checking is not performed.

Encoding

  This string annotation serves the same purpose as the `Encoding` argument annotation when applied to the mapped type being defined.

NoTypeName

  This boolean annotation specifies that the definition of the type rather than the name of the type being defined should be used in the generated code.

  Normally a typedef would be defined as follows:

      typedef bool MyBool;

  This would result in `MyBool` being used in the generated code.

  Specifying the annotation means that `bool` will be used in the generated code instead.

PyInt

  This boolean annotation serves the same purpose as the `PyInt` argument annotation when applied to the type being defined.

PyName

  This name annotation only applies when the typedef is being used to create the wrapping for a class defined using a template and specifies an alternative name for the class when it is referred to from Python.

  See also

  `%AutoPyName`

TypeHint

  This string annotation specifies the type as it will appear in any generated docstrings and PEP 484 type hints. It is the equivalent of specifying `TypeHintIn` and `TypeHintOut` with the same value.

TypeHintIn

  This string annotation specifies the type as it will appear in any generated docstrings and PEP 484 type hints when it is passed to a function (rather than being returned from a function). It is usually used with arguments of type `SIP_PYOBJECT` to provide a more specific type.

TypeHintOut

  This string annotation specifies the type as it will appear in any generated docstrings and PEP 484 type hints when it is returned from a function (rather than being passed to a function). It is usually used with arguments of type `SIP_PYOBJECT` to provide a more specific type.

## Variable Annotations

Encoding

  This string annotation serves the same purpose as the `Encoding` argument annotation when applied to the type of the variable being defined.

NoSetter

  This boolean annotation specifies that the variable will have no setter and will be read-only. Because SIP does not fully understand C/C++ types (particularly `const` arrays) it is sometimes necessary to explicitly annotate a variable as being read-only.

NoTypeHint

  This boolean annotation is used to suppress the generation of the PEP 484 type hint for the variable.

PyInt

  This boolean annotation serves the same purpose as the `PyInt` argument annotation when applied to the type of the variable being defined.

PyName

  This name annotation specifies an alternative name for the variable being wrapped which is used when it is referred to from Python.

  See also

  `%AutoPyName`

TypeHint

  This string annotation specifies the type of the variable as it will appear in any generated docstrings and PEP 484 type hints. It is usually used with arguments of type `SIP_PYOBJECT` to provide a more specific type.