-
- Notifications
You must be signed in to change notification settings - Fork 3k
Closed as not planned
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
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
from array import array x: 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"
Possible Workaround
from array import array from typing import TYPE_CHECKING if TYPE_CHECKING: IntArray = array[int] else: IntArray = array x: IntArray = array("L")
Your Environment
- Mypy version used:
mypy 0.982 (compiled: yes)
- Mypy command-line flags:
mypy --strict
- Mypy configuration options from
mypy.ini
(and other config files): None - Python version used:
3.9.13
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong