typeshed
typeshed copied to clipboard
Add a JSON alias
Cf. python/typing#182
I have deliberately not added this to any existing stubs, since that might be disruptive and needs experimentation independent from the alias itself.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
I don't see how this would be useful:
- Because of invariance, a
dict[str, str]is not a validJSON. This makesJSONquite useless for argument types. - We don't have weak unions or
AnyOf, soJSONis not good for return types: you would need toassertthe structure of the JSON to get anything done.
We should now be able to use a properly recursive type.
However, I share the reservations about adding this if we don't know how we'll use it. I think invariance makes it so that we can't really use this alias anywhere in typeshed.