Closed lgautier closed 2 hours ago
Try using from __future__ import annotations
, string literal annotations (memoryview[int]
-> "memoryview[int]"
), or an if TYPE_CHECKING:
alias.
(memoryview
was made generic in typeshed quite recently in https://github.com/python/typeshed/pull/12247. I don't the background here, but it seems like if memoryview
is going to be generic in the stubs, we should eventually add memoryview.__class_getitem__
upstream? I couldn't find an existing CPython issue for this)
Thanks. Adding from __future__ import annotations
does solve the issue. I had understood from the doc page you mentioned that this was only for Python 3.8 or earlier.
Bug Report
Specifying a subtype for
memoryview
is required to pass mypy checks, but this create aTypeError
in Python.To Reproduce
This fails mypy checks:
Fixing mypy checks triggers Python error:
Expected Behavior
Actual Behavior
Either mypy fails but Python can run the code, or mypy passes but Python doesn't run.
Your Environment