-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
v1.15.0 breaking checks using Coroutine #18634
Labels
bug
mypy got something wrong
Comments
gabrielcocenza
added a commit
to gabrielcocenza/charmed-openstack-upgrader-1
that referenced
this issue
Feb 7, 2025
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 I propose we pin the version to lower than the new release until the upstream code fix it.
This is intentional. You can have coroutines without from typing import Coroutine
def compare_step_coroutines(
coro1: Coroutine, coro2: Coroutine
) -> bool:
assert hasattr(coro1, "cr_code")
assert hasattr(coro2, "cr_code")
return coro1.cr_code == coro2.cr_code Comment I left on typeshed for more information: python/typeshed#10816 (comment) |
Note of course that the more correct thing to check is from typing import Coroutine
from types import CoroutineType
def test1(
coro: Coroutine
) -> None:
assert isinstance(coro, CoroutineType)
reveal_type(coro.cr_code) # N: Revealed type is "types.CodeType"
def test2(
coro: Coroutine
) -> None:
assert hasattr(coro, "cr_code")
reveal_type(coro.cr_code) # N: Revealed type is "Any" |
gabrielcocenza
added a commit
to gabrielcocenza/charmed-openstack-upgrader-1
that referenced
this issue
Feb 10, 2025
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
gabrielcocenza
added a commit
to gabrielcocenza/charmed-openstack-upgrader-1
that referenced
this issue
Feb 10, 2025
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
samuelallan72
pushed a commit
to canonical/charmed-openstack-upgrader
that referenced
this issue
Feb 10, 2025
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
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Bug Report
Since the new release, one of the projects that I use mypy is failing for the type Coroutine.
The code is like this:
With this new release Coroutine doesn't recognize cr_code as a valid property.
I've tried to change to use
types.CoroutineType
and fixed for this issue, but errors started showing on other parts of the code. mypy still consider asCoroutine
. E.g:Basically
Coroutine
cannot be used anymore like before and I don't see a possible workaround without ignoring the line that is complaining or pinning mypy to use a version <1.15.0
Your Environment
mypy --install-types --non-interactive .
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: