Skip to content

MemoryXXXChannel doesn't support generic typing #1327

@pipermerriam

Description

@pipermerriam

When using mypy and type hints for trio.abc.SendChannel and trio.abc.ReceiveChannel, mypy complains about calling things like:

  • channel.clone()
  • channel.send_nowait()

This is because trio.abc.XXXChannel don't have these interfaces, only the MemoryXXXChannel does. The problem is that the trio.abc.SendChannel allow for specifying the type of object that passes through the channel via trio.abc.SendChannel[SomeType], however, the MemoryXXXChannel objects do not.

Both of the solutions for this are not ideal.

  • cast(MemoryXXXChannel, my_channel): this loses the object type that passes through the channel.
  • # type: ignore: this just silences the error....

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions