Skip to content

Commit 8f0d230

Browse files
fix(types): allow pyright to infer TypedDict types within SequenceNotStr
1 parent 9a993f2 commit 8f0d230

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/openai/_types.py

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

0 commit comments

Comments
 (0)