Skip to content

Commit 265bdf4

Browse files
Merge pull request #316 from OneBusAway/release-please--branches--main--changes--next
release: 1.15.5
2 parents 6b7495a + 0d9448a commit 265bdf4

File tree

8 files changed

+61
-5
lines changed

8 files changed

+61
-5
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.15.4"
2+
".": "1.15.5"
33
}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 1.15.5 (2025-08-30)
4+
5+
Full Changelog: [v1.15.4...v1.15.5](https://github.com/OneBusAway/python-sdk/compare/v1.15.4...v1.15.5)
6+
7+
### Chores
8+
9+
* **internal:** add Sequence related utils ([767a34a](https://github.com/OneBusAway/python-sdk/commit/767a34a8634d836ec05bc577e640df14416dd9c2))
10+
311
## 1.15.4 (2025-08-27)
412

513
Full Changelog: [v1.15.3...v1.15.4](https://github.com/OneBusAway/python-sdk/compare/v1.15.3...v1.15.4)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "onebusaway"
3-
version = "1.15.4"
3+
version = "1.15.5"
44
description = "The official Python library for the onebusaway-sdk API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"

src/onebusaway/_types.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,21 @@
1313
Mapping,
1414
TypeVar,
1515
Callable,
16+
Iterator,
1617
Optional,
1718
Sequence,
1819
)
19-
from typing_extensions import Set, Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
20+
from typing_extensions import (
21+
Set,
22+
Literal,
23+
Protocol,
24+
TypeAlias,
25+
TypedDict,
26+
SupportsIndex,
27+
overload,
28+
override,
29+
runtime_checkable,
30+
)
2031

2132
import httpx
2233
import pydantic
@@ -217,3 +228,26 @@ class _GenericAlias(Protocol):
217228
class HttpxSendArgs(TypedDict, total=False):
218229
auth: httpx.Auth
219230
follow_redirects: bool
231+
232+
233+
_T_co = TypeVar("_T_co", covariant=True)
234+
235+
236+
if TYPE_CHECKING:
237+
# This works because str.__contains__ does not accept object (either in typeshed or at runtime)
238+
# https://github.com/hauntsaninja/useful_types/blob/5e9710f3875107d068e7679fd7fec9cfab0eff3b/useful_types/__init__.py#L285
239+
class SequenceNotStr(Protocol[_T_co]):
240+
@overload
241+
def __getitem__(self, index: SupportsIndex, /) -> _T_co: ...
242+
@overload
243+
def __getitem__(self, index: slice, /) -> Sequence[_T_co]: ...
244+
def __contains__(self, value: object, /) -> bool: ...
245+
def __len__(self) -> int: ...
246+
def __iter__(self) -> Iterator[_T_co]: ...
247+
def index(self, value: Any, start: int = 0, stop: int = ..., /) -> int: ...
248+
def count(self, value: Any, /) -> int: ...
249+
def __reversed__(self) -> Iterator[_T_co]: ...
250+
else:
251+
# just point this to a normal `Sequence` at runtime to avoid having to special case
252+
# deserializing our custom sequence type
253+
SequenceNotStr = Sequence

src/onebusaway/_utils/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
extract_type_arg as extract_type_arg,
3939
is_iterable_type as is_iterable_type,
4040
is_required_type as is_required_type,
41+
is_sequence_type as is_sequence_type,
4142
is_annotated_type as is_annotated_type,
4243
is_type_alias_type as is_type_alias_type,
4344
strip_annotated_type as strip_annotated_type,

src/onebusaway/_utils/_typing.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ def is_list_type(typ: type) -> bool:
2626
return (get_origin(typ) or typ) == list
2727

2828

29+
def is_sequence_type(typ: type) -> bool:
30+
origin = get_origin(typ) or typ
31+
return origin == typing_extensions.Sequence or origin == typing.Sequence or origin == _c_abc.Sequence
32+
33+
2934
def is_iterable_type(typ: type) -> bool:
3035
"""If the given type is `typing.Iterable[T]`"""
3136
origin = get_origin(typ) or typ

src/onebusaway/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
__title__ = "onebusaway"
4-
__version__ = "1.15.4" # x-release-please-version
4+
__version__ = "1.15.5" # x-release-please-version

tests/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import inspect
55
import traceback
66
import contextlib
7-
from typing import Any, TypeVar, Iterator, cast
7+
from typing import Any, TypeVar, Iterator, Sequence, cast
88
from datetime import date, datetime
99
from typing_extensions import Literal, get_args, get_origin, assert_type
1010

@@ -15,6 +15,7 @@
1515
is_list_type,
1616
is_union_type,
1717
extract_type_arg,
18+
is_sequence_type,
1819
is_annotated_type,
1920
is_type_alias_type,
2021
)
@@ -71,6 +72,13 @@ def assert_matches_type(
7172
if is_list_type(type_):
7273
return _assert_list_type(type_, value)
7374

75+
if is_sequence_type(type_):
76+
assert isinstance(value, Sequence)
77+
inner_type = get_args(type_)[0]
78+
for entry in value: # type: ignore
79+
assert_type(inner_type, entry) # type: ignore
80+
return
81+
7482
if origin == str:
7583
assert isinstance(value, str)
7684
elif origin == int:

0 commit comments

Comments
 (0)