-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
mypy should use CoroutineType instead of Coroutine for return types of async def functions #18635
Comments
Since the new release of the new mypy version (1.15.0), our lint started failing. The bug discription can be found here: - python/mypy#18634 Until mypy start returning CoroutineType for async functions, we need to ensure that Coroutine has `cr_code`: - python/mypy#18635
Since the new release of the new mypy version (1.15.0), our lint started failing. The bug discription can be found here: - python/mypy#18634 Until mypy start returning CoroutineType for async functions, we need to ensure that Coroutine has `cr_code`: - python/mypy#18635
Since the new release of the new mypy version (1.15.0), our lint started failing. The bug discription can be found here: - python/mypy#18634 Until mypy start returning CoroutineType for async functions, we need to ensure that Coroutine has `cr_code`: - python/mypy#18635
One slight complication is that the coroutines Cython returns do not pass an And wouldn't you guess it, turns out they commented out a test checking this? https://github.com/cython/cython/blob/5084ea9a3be311b771baf3cdafe464914f86ec35/tests/run/test_coroutines_pep492.pyx#L879 (compared to the cpython test: https://github.com/python/cpython/blob/aa845af9bb39b3e2ed08bbb00a8e932a97be8fc0/Lib/test/test_coroutines.py#L537) |
I posted this elsewhere but it's worth emphasising here: Cython Coroutines simply cannot be of type Unlike CPython and PyPy, Cython is not a standalone Python implementation so we do not get to control what the system regards as I suspect the upshot of this is that it is not appropriate to use mypy on Cython modules because MyPy demands a level of strictness about types that it is not possible for something like Cython to meet. |
I agree that it's not a bug for Cython to have its own coroutine type. In fact it's in line with the idea behind the A practical issue might be that people often want to access attributes like |
Feature
types.CoroutineType is defined as:
Evidently, async def functions return them. For context, they're a subclass of
collections.abc.Coroutine
with extra features.Pitch
#18634 ran into this.
The text was updated successfully, but these errors were encountered: