Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemoryXXXChannel doesn't support generic typing #1327

Closed
pipermerriam opened this issue Dec 2, 2019 · 0 comments · Fixed by #2549
Closed

MemoryXXXChannel doesn't support generic typing #1327

pipermerriam opened this issue Dec 2, 2019 · 0 comments · Fixed by #2549

Comments

@pipermerriam
Copy link

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....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants