字节编码字典的正确类型提示是什么?

sup*_*odo 5 types python-3.x

我有一本字典,键是用字节串编码的字典:

mydict = {
   b'{"key 1": 3, "key 2": 6}': 'my first value',
   b'{"key 1": 2, "key 2": 7}': 'my second value',
}
Run Code Online (Sandbox Code Playgroud)

我想知道如何编写类型提示。
在我看来,这是有道理的:

from typing import Dict, ByteString

mydict: Dict[ByteString[Dict[str, int]], str] = {
   b'{"key 1": 3, "key 2": 6}': 'my first value',
   b'{"key 1": 2, "key 2": 7}': 'my second value',
}
Run Code Online (Sandbox Code Playgroud)

但我得到TypeError: typing.ByteString is not a generic class
任何建议吗?

For*_*Bru 6

很简单dict[bytes, str]- Python 不理解bytes.

同样, 的类型"6"是字符串,而不是“包含整数的字符串”,并且"(1, 2)"也是简单字符串,而不是包含整数元组的字符串。

Maybe the closest thing to "typing a string" are template literal strings in TypeScript, but it's still not the same. A string is just a string - it can't be parametrised.