Skip to content

Dataclasses are not working in scripts #537

Closed
@binaryaaron

Description

@binaryaaron

Hi! First off, it's am amazing framework and I love using it instead of a billion yaml files to run my house. Thanks for your efforts.

I just noticed that a simple dataclass doesn't work, likely due to lack of an async def ast_annassign(...) function in eval.py.

e.g., i've had an existing script that broke after upgrading to 1.5 + HASS 2023.10.0

from dataclasses import dataclass

...

@dataclass
class HVACSettings:
    mode: str
    temp: int
    fan_speed: str
    time_trigger: str

and in my logs:

2023-10-18 14:47:57.010 ERROR (MainThread) [custom_components.pyscript.file.hvac] Exception in </config/pyscript/hvac.py> line 53:
        mode: str
        ^
NotImplementedError: file.hvac: not implemented ast ast_annassign

Curious if this was ever supposed to work or something else has changed. Could probably make a PR here to fix if you think adding the ast_anassign method is "right".

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