Closed as not planned
Description
Bug Report
ReadOnly
is in typing-extensions
but we can't use it with MyPy (but we can with PyRight)
To Reproduce
from typing import TypedDict, Hashable
from typing_extensions import ReadOnly
class Animal(TypedDict):
name: ReadOnly[Hashable]
class Cat(TypedDict):
name: str
cat: Animal(name='Toby')
https://gist.github.com/mypy-play/39923f5d02befb8d559583b702103391
Expected Behavior
No issues reported (which is what happens with PyRight)
Actual Behavior
main.py:5: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]
main.py:5: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
main.py:10: error: Invalid type comment or annotation [valid-type]
main.py:10: note: Suggestion: use Animal[...] instead of Animal(...)
Found 2 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.11.12
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini
(and other config files): - Python version used: 3.12