Skip to content

Add "Dict" to typehints for ZenEngine.create_decision in zen.pyi #419

@SJonesy

Description

@SJonesy

ZenDecisionContentInput: TypeAlias = Union[str, ZenDecisionContent]

ZenEngine.create_decision() happily takes a dict:

>>> import json
>>> import zen
>>> z = zen.ZenEngine()
>>> jdm = open("/tmp/decision.json").read()
>>> jdm_dict = json.loads(jdm)
>>> decision = z.create_decision(jdm_dict)
>>> context = """
... {
...     "event": {
...         "event_type": "KillEvent",
...         "source": 123
...     },
...     "account": {
...         "battle_player_id": 123
...     }
... }
... """
>>> result = decision.evaluate(context)
>>> result
{'performance': '2.8ms', 'result': {'account': {'battle_player_id': 123}, 'event': {'event_type': 'KillEvent', 'source': 123}, 'quest_complete': True}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions