Skip to content

Commit c8d571c

Browse files
fix(types): allow pyright to infer TypedDict types within SequenceNotStr
1 parent 84a794c commit c8d571c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/kernel/_types.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ class HttpxSendArgs(TypedDict, total=False):
243243
if TYPE_CHECKING:
244244
# This works because str.__contains__ does not accept object (either in typeshed or at runtime)
245245
# https://github.com/hauntsaninja/useful_types/blob/5e9710f3875107d068e7679fd7fec9cfab0eff3b/useful_types/__init__.py#L285
246+
#
247+
# Note: index() and count() methods are intentionally omitted to allow pyright to properly
248+
# infer TypedDict types when dict literals are used in lists assigned to SequenceNotStr.
246249
class SequenceNotStr(Protocol[_T_co]):
247250
@overload
248251
def __getitem__(self, index: SupportsIndex, /) -> _T_co: ...
@@ -251,8 +254,6 @@ def __getitem__(self, index: slice, /) -> Sequence[_T_co]: ...
251254
def __contains__(self, value: object, /) -> bool: ...
252255
def __len__(self) -> int: ...
253256
def __iter__(self) -> Iterator[_T_co]: ...
254-
def index(self, value: Any, start: int = 0, stop: int = ..., /) -> int: ...
255-
def count(self, value: Any, /) -> int: ...
256257
def __reversed__(self) -> Iterator[_T_co]: ...
257258
else:
258259
# just point this to a normal `Sequence` at runtime to avoid having to special case

0 commit comments

Comments
 (0)