Pyscript: Running HA core code that is not part of a service

Hopefully I’m using the correct terms here… I want to run a delete_event script in Pyscript, but the code is not yet implemented in HA as a service call. The calendar documentation is here.

To do this, I went into the example code on the page, and I attempted to include it in my pyscripts .py file. The code, rudimentary as it is, is below:

from homeassistant.core import HomeAssistant
from homeassistant.components.calendar import CalendarEntity
from homeassistant.helpers.entity import Entity, EntityDescription

Entity = "calendar.test"

class CalendarEntity(Entity):

    async def async_delete_event(
        self,
        uid: str,
        recurrence_id: str | None = None,
        recurrence_range: str | None = None,
        ) -> None:
        """Delete an event on the calendar."""


# Define a coroutine to call the async method
async def main():
    await CalendarEntity(Entity).async_delete_event(uid="XXXXXXX")

# Run the coroutine in the event loop
asyncio.run(main())

Conceptually, is this even possible? Can I use example code, bring in the same imports as were on the HA Core Github page, and then run it? When I do so currently, I get the very unhelpful “Exception” error in the logs, pointing to line 24, which is this:

recurrence_range: str | None = None,

I doubt that I’m being very clear, but I’m happy to clarify if it’s helpful.