Skip to content

field

Canonical path: o6.field

field

field(
    *,
    name=None,
    description=None,
    isOptional=False,
    valueRank=None,
    arrayDimensions=None,
    maxStringLength=None
)

Attach OPC UA metadata to an annotated DataType field.

Used as the assigned value of an annotated attribute in a @o6.datatype class body. The annotation still supplies the field's static type, so this factory deliberately returns Any to type checkers and adds only what the annotation cannot express.

@o6.datatype(ns="plant")
class BatchRecord:
    batchId: str
    comment: Optional[str] = o6.field(description="free-text operator note")
    tag: str = o6.field(maxStringLength=32)

Parameters:

Name Type Description Default
name Optional[str]

OPC UA field name. This renames the Python attribute along with the wire field, so it is mainly useful when a UA field name is not a valid Python identifier.

None
description Optional[str]

The field's Description in the StructureDefinition.

None
isOptional bool

Mark the field optional. Optional[T] in the annotation does the same thing and is the form to prefer.

False
valueRank Optional[int]

Override the rank inferred from the annotation. Structure members must be scalars (-1) or 1-D arrays (1); anything else is rejected, because open62541 cannot represent a multi-dimensional array as a structure member.

None
arrayDimensions Optional[list[int]]

ArrayDimensions of the field.

None
maxStringLength Optional[int]

Length hint for a String or ByteString field.

None

See Field metadata with o6.field.