Skip to content

VariantType and SecurityPolicyType should be IntEnum #1634

@dakotahorstman

Description

@dakotahorstman

Describe the bug

Attempts to serialize an object with SecurityPolicyType or VariantType attributes fail. Enums cannot be serialized. Changing them to IntEnum makes them serializable, plus they are already effectively IntEnums based on their implementation (i.e. named_attribute = int).

To Reproduce

import json
from asyncua.ua import VariantType, SecurityPolicyType

json.dumps({"variant": VariantType.Boolean, "security_policy": SecurityPolicyType.None})

>>> `TypeError: Object of type VariantType is not JSON serializable`
OR
>>> `TypeError: Object of type SecurityPolicyType is not JSON serializable`

Expected behavior

Serialization to succeed.

Version

Python-Version:3.12
opcua-asyncio Version (e.g. master branch, 0.9): 1.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions