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
Mypy strict mode complains if a type parameter is omitted when using the built-in array type in an annotation, while Python raises TypeError if a type parameter is included. Mypy only complains in strict mode.
To Reproduce
fromarrayimportarrayx: array=array("L") # Mypy error: Missing type parameters for generic type "array"y: array[int] =array("L") # TypeError: 'type' object is not subscriptable
Expected Behavior
Mypy strict mode should not complain about a missing generic type parameter (since Python does not allow it).
Actual Behavior
array-mypy.py:2: error: Missing type parameters for generic type "array"
However, in this case we should probably make array support __class_getitem__ at runtime. I can't find a reason why we didn't do that before. I'll submit an issue to CPython to make that change, but it won't be released until 3.12.
The array class is not subscriptable in Python 3.11 and older, causing
a TypeError at runtime. This patch applies the workaround suggested in
python/mypy#13942.
The array class is not subscriptable in Python 3.11 and older, causing
a TypeError at runtime. This patch applies the workaround suggested in
python/mypy#13942.
Bug Report
Mypy strict mode complains if a type parameter is omitted when using the built-in
array
type in an annotation, while Python raisesTypeError
if a type parameter is included. Mypy only complains in strict mode.To Reproduce
Expected Behavior
Mypy strict mode should not complain about a missing generic type parameter (since Python does not allow it).
Actual Behavior
Possible Workaround
Your Environment
mypy 0.982 (compiled: yes)
mypy --strict
mypy.ini
(and other config files): None3.9.13
The text was updated successfully, but these errors were encountered: