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

No type inference for Response type in collector when using PyCharm #15

Open
JosXa opened this issue Oct 19, 2020 · 1 comment
Open
Labels
bug Something isn't working help wanted Extra attention is needed looking for opinions

Comments

@JosXa
Copy link
Owner

JosXa commented Oct 19, 2020

When using async with controller.collect(...) as response, PyCharm fails to understand the AsyncContextManager[Response] type annotation and infers response as Any.

This is due to a bug in PyCharm itself, which is reported on their YouTrack board (and not planned since two years): https://youtrack.jetbrains.com/issue/PY-29891

If someone wants to look into this, here are the relevant type annotations:

Now, since this is the integral part of tgintegration, we need to find a solution (Update 2020-10-25: # type: Response has been added to all examples):

  1. Leave it as it is, wait for and push JetBrains to fix the bug (I'd need help from the community for that). Add documentation on how to use typing.cast or as response: # type: Response as workarounds.
  2. Keep trying to find another workaround that will make PyCharm happy.
  3. Re-architect the @asynccontextmanager design (please no, I find it great 🤦)
@JosXa JosXa added bug Something isn't working help wanted Extra attention is needed looking for opinions labels Oct 19, 2020
JosXa added a commit that referenced this issue Oct 19, 2020
JosXa pushed a commit that referenced this issue Oct 24, 2020
@JosXa
Copy link
Owner Author

JosXa commented Sep 4, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed looking for opinions
Projects
None yet
Development

No branches or pull requests

1 participant