Skip to content

Consider switching to Sequence over lists for arguments #305

Description

@leddy231

This is probably an issue in more places but I noticed it on the list of triggers.
The following example code:

from inngest import  TriggerEvent
from inngest.client import inngest_client

client = inngest_client("test")

triggers = [TriggerEvent(event="some_event")]

@client.create_function(fn_id="test_function", trigger=triggers)
async def test_function(context):
    return "Hello world."

Gives this type error in VSCode

Argument of type "list[TriggerEvent]" cannot be assigned to parameter "trigger" of type "TriggerCron | TriggerEvent | list[TriggerCron | TriggerEvent]" in function "create_function"
  Type "list[TriggerEvent]" is not assignable to type "TriggerCron | TriggerEvent | list[TriggerCron | TriggerEvent]"
    "list[TriggerEvent]" is not assignable to "TriggerCron"
    "list[TriggerEvent]" is not assignable to "TriggerEvent"
    "list[TriggerEvent]" is not assignable to "list[TriggerCron | TriggerEvent]"
      Type parameter "_T@list" is invariant, but "TriggerEvent" is not the same as "TriggerCron | TriggerEvent"
      Consider switching from "list" to "Sequence" which is covariant

Switching to Sequence would solve the type error, and should work the same in code since the lists are never modified from what I can see.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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