Further improve and simplify pyright configuration (#9714)

This commit is contained in:
Avasam
2023-02-12 16:42:23 -05:00
committed by GitHub
parent a768744d51
commit 965b3108fe
4 changed files with 47 additions and 34 deletions

View File

@@ -20,6 +20,9 @@ _VT = TypeVar("_VT")
class KeysAndGetItem(Generic[_KT, _VT]):
data: dict[_KT, _VT]
def __init__(self, data: dict[_KT, _VT]) -> None:
self.data = data
def keys(self) -> Iterable[_KT]:
return self.data.keys()
@@ -27,11 +30,11 @@ class KeysAndGetItem(Generic[_KT, _VT]):
return self.data[__k]
kt1: KeysAndGetItem[int, str] = KeysAndGetItem()
kt1: KeysAndGetItem[int, str] = KeysAndGetItem({0: ""})
assert_type(dict(kt1), Dict[int, str])
dict(kt1, arg="a") # type: ignore
kt2: KeysAndGetItem[str, int] = KeysAndGetItem()
kt2: KeysAndGetItem[str, int] = KeysAndGetItem({"": 0})
assert_type(dict(kt2, arg=1), Dict[str, int])