You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a detailed description of the bug or problem you are having
output of pip list from the virtual environment you are using
pytest and operating system versions
minimal example if possible
Pytest complains that Synchronized is not subscriptable, whether you get it direct from multiprocessing, or from typeshed. I haven't dug into why. I'd be curious to hear if anyone is using Pytest with a "subscripted" Synchronized type.
I am using mypy 1.10.0 which I think should support the use of Synchronized here. Same behavior on 3.9 and 3.12. Both installed with brew on M1 macOS 14.4.1.
The simplest way to illustrate the problem is with these two files:
This results in a world where mypy complains (unless told to ignore) about assigning a float to a c_double. But that's fine - the type checker is still helping me by making me check that the assignment makes sense.
running pytest in a directory with these two files results in:
___________________________________________ ERROR collecting test_define_type.py ___________________________________________
test_define_type.py:1: in <module>
from define_type import a_value
define_type.py:7: in <module>
def a_value() -> Synchronized[ctypes.c_double]:
E TypeError: type 'Synchronized' is not subscriptable
Like I mentioned, I see this on 3.9 and 3.12 (the only versions I tested), but here's the pip list from the 3.12 venv:
Note that mypy will complain about duplicate files if I try including Synchronized from typeshed. So, this could be addressed by mypy somehow giving me a Synchronized type that will work with pytest. But maybe this is pytest's problem. I'm cross-posting with python/typeshed#8799 (comment), which includes more discussion of using Values with mypy.
The text was updated successfully, but these errors were encountered:
The most likely explanation is that Synchronized is only generic in typeshed, but not in runtime, which makes Synchronized[double] valid for mypy but invalid at runtime. The fix is to quote it like "Synchronized[double]" or to add from __future__ import annotations to the top of your file.
pip list
from the virtual environment you are usingPytest complains that Synchronized is not subscriptable, whether you get it direct from multiprocessing, or from typeshed. I haven't dug into why. I'd be curious to hear if anyone is using Pytest with a "subscripted" Synchronized type.
I am using mypy 1.10.0 which I think should support the use of Synchronized here. Same behavior on 3.9 and 3.12. Both installed with brew on M1 macOS 14.4.1.
The simplest way to illustrate the problem is with these two files:
This results in a world where mypy complains (unless told to ignore) about assigning a float to a c_double. But that's fine - the type checker is still helping me by making me check that the assignment makes sense.
running pytest in a directory with these two files results in:
Like I mentioned, I see this on 3.9 and 3.12 (the only versions I tested), but here's the pip list from the 3.12 venv:
Note that mypy will complain about duplicate files if I try including
Synchronized
from typeshed. So, this could be addressed by mypy somehow giving me a Synchronized type that will work with pytest. But maybe this is pytest's problem. I'm cross-posting with python/typeshed#8799 (comment), which includes more discussion of usingValue
s with mypy.The text was updated successfully, but these errors were encountered: