Skip to content

Commit ede3242

Browse files
fix(types): allow pyright to infer TypedDict types within SequenceNotStr
1 parent 4547171 commit ede3242

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/anthropic/_types.py

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

0 commit comments

Comments
 (0)