Skip to content

Commit fcaf9a7

Browse files
authored
Merge pull request #74 from steel-dev/release-please--branches--main--changes--next
release: 0.1.0-beta.9
2 parents 8179ae6 + d02921b commit fcaf9a7

File tree

16 files changed

+154
-31
lines changed

16 files changed

+154
-31
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-
".": "0.1.0-beta.8"
2+
".": "0.1.0-beta.9"
33
}

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 9
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nen-labs%2Fsteel-6e32c08e5d67ffd976fafcf67f671bb69024a4a827f22e89988098d682ed5c60.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nen-labs%2Fsteel-9b418de74a20cd1828e67c620c627a54e0f57219d44cba0a48c9e644f5336c9e.yml

CHANGELOG.md

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

3+
## 0.1.0-beta.9 (2025-02-21)
4+
5+
Full Changelog: [v0.1.0-beta.8...v0.1.0-beta.9](https://github.com/steel-dev/steel-python/compare/v0.1.0-beta.8...v0.1.0-beta.9)
6+
7+
### Features
8+
9+
* **api:** api update ([#82](https://github.com/steel-dev/steel-python/issues/82)) ([c2b468e](https://github.com/steel-dev/steel-python/commit/c2b468ea3fbdd36633d3539fda857164b4407d32))
10+
* **client:** allow passing `NotGiven` for body ([#81](https://github.com/steel-dev/steel-python/issues/81)) ([5634d78](https://github.com/steel-dev/steel-python/commit/5634d78a94c580216e7c2a96a5de34b308320f65))
11+
* **client:** send `X-Stainless-Read-Timeout` header ([#75](https://github.com/steel-dev/steel-python/issues/75)) ([9c82e52](https://github.com/steel-dev/steel-python/commit/9c82e52cac086b4dfef6f4c531990887c0d06cd6))
12+
13+
14+
### Bug Fixes
15+
16+
* asyncify on non-asyncio runtimes ([#79](https://github.com/steel-dev/steel-python/issues/79)) ([5dc2c1e](https://github.com/steel-dev/steel-python/commit/5dc2c1eb47698bce547a4d65899b4723f299b1be))
17+
* **client:** mark some request bodies as optional ([5634d78](https://github.com/steel-dev/steel-python/commit/5634d78a94c580216e7c2a96a5de34b308320f65))
18+
19+
20+
### Chores
21+
22+
* **internal:** bummp ruff dependency ([#73](https://github.com/steel-dev/steel-python/issues/73)) ([549e327](https://github.com/steel-dev/steel-python/commit/549e32725828a1549827a774334e9d5b6efdfc33))
23+
* **internal:** change default timeout to an int ([#72](https://github.com/steel-dev/steel-python/issues/72)) ([571a926](https://github.com/steel-dev/steel-python/commit/571a92692803a75b4a34b80ec76ecd1d75dea899))
24+
* **internal:** fix type traversing dictionary params ([#76](https://github.com/steel-dev/steel-python/issues/76)) ([f116d3d](https://github.com/steel-dev/steel-python/commit/f116d3dba8ae1ca3f576f7f533d2aeb62693b14d))
25+
* **internal:** minor type handling changes ([#77](https://github.com/steel-dev/steel-python/issues/77)) ([f5a1ec4](https://github.com/steel-dev/steel-python/commit/f5a1ec481228186b388cf86b75f0d14c067ad818))
26+
* **internal:** update client tests ([#78](https://github.com/steel-dev/steel-python/issues/78)) ([03074e5](https://github.com/steel-dev/steel-python/commit/03074e5bf7f08e50debff7d7c7ecf78149d8cd8d))
27+
* **internal:** update client tests ([#80](https://github.com/steel-dev/steel-python/issues/80)) ([e076ecf](https://github.com/steel-dev/steel-python/commit/e076ecfa88045ead462069385b8dc07408d85911))
28+
329
## 0.1.0-beta.8 (2025-01-29)
430

531
Full Changelog: [v0.1.0-beta.7...v0.1.0-beta.8](https://github.com/steel-dev/steel-python/compare/v0.1.0-beta.7...v0.1.0-beta.8)

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "steel-sdk"
3-
version = "0.1.0-beta.8"
3+
version = "0.1.0-beta.9"
44
description = "The official Python library for the steel API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"
@@ -177,7 +177,7 @@ select = [
177177
"T201",
178178
"T203",
179179
# misuse of typing.TYPE_CHECKING
180-
"TCH004",
180+
"TC004",
181181
# import rules
182182
"TID251",
183183
]

requirements-dev.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pytz==2023.3.post1
7878
# via dirty-equals
7979
respx==0.22.0
8080
rich==13.7.1
81-
ruff==0.6.9
81+
ruff==0.9.4
8282
setuptools==68.2.2
8383
# via nodeenv
8484
six==1.16.0

scripts/utils/ruffen-docs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _md_match(match: Match[str]) -> str:
4747
with _collect_error(match):
4848
code = format_code_block(code)
4949
code = textwrap.indent(code, match["indent"])
50-
return f'{match["before"]}{code}{match["after"]}'
50+
return f"{match['before']}{code}{match['after']}"
5151

5252
def _pycon_match(match: Match[str]) -> str:
5353
code = ""
@@ -97,7 +97,7 @@ def finish_fragment() -> None:
9797
def _md_pycon_match(match: Match[str]) -> str:
9898
code = _pycon_match(match)
9999
code = textwrap.indent(code, match["indent"])
100-
return f'{match["before"]}{code}{match["after"]}'
100+
return f"{match['before']}{code}{match['after']}"
101101

102102
src = MD_RE.sub(_md_match, src)
103103
src = MD_PYCON_RE.sub(_md_pycon_match, src)

src/steel/_base_client.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,17 @@ def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0
418418
if idempotency_header and options.method.lower() != "get" and idempotency_header not in headers:
419419
headers[idempotency_header] = options.idempotency_key or self._idempotency_key()
420420

421-
# Don't set the retry count header if it was already set or removed by the caller. We check
421+
# Don't set these headers if they were already set or removed by the caller. We check
422422
# `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case.
423-
if "x-stainless-retry-count" not in (header.lower() for header in custom_headers):
423+
lower_custom_headers = [header.lower() for header in custom_headers]
424+
if "x-stainless-retry-count" not in lower_custom_headers:
424425
headers["x-stainless-retry-count"] = str(retries_taken)
426+
if "x-stainless-read-timeout" not in lower_custom_headers:
427+
timeout = self.timeout if isinstance(options.timeout, NotGiven) else options.timeout
428+
if isinstance(timeout, Timeout):
429+
timeout = timeout.read
430+
if timeout is not None:
431+
headers["x-stainless-read-timeout"] = str(timeout)
425432

426433
return headers
427434

@@ -511,7 +518,7 @@ def _build_request(
511518
# so that passing a `TypedDict` doesn't cause an error.
512519
# https://github.com/microsoft/pyright/issues/3526#event-6715453066
513520
params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None,
514-
json=json_data,
521+
json=json_data if is_given(json_data) else None,
515522
files=files,
516523
**kwargs,
517524
)

src/steel/_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
OVERRIDE_CAST_TO_HEADER = "____stainless_override_cast_to"
77

88
# default timeout is 1 minute
9-
DEFAULT_TIMEOUT = httpx.Timeout(timeout=60.0, connect=5.0)
9+
DEFAULT_TIMEOUT = httpx.Timeout(timeout=60, connect=5.0)
1010
DEFAULT_MAX_RETRIES = 2
1111
DEFAULT_CONNECTION_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20)
1212

src/steel/_models.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def to_json(
172172
@override
173173
def __str__(self) -> str:
174174
# mypy complains about an invalid self arg
175-
return f'{self.__repr_name__()}({self.__repr_str__(", ")})' # type: ignore[misc]
175+
return f"{self.__repr_name__()}({self.__repr_str__(', ')})" # type: ignore[misc]
176176

177177
# Override the 'construct' method in a way that supports recursive parsing without validation.
178178
# Based on https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836.
@@ -426,10 +426,16 @@ def construct_type(*, value: object, type_: object) -> object:
426426
427427
If the given value does not match the expected type then it is returned as-is.
428428
"""
429+
430+
# store a reference to the original type we were given before we extract any inner
431+
# types so that we can properly resolve forward references in `TypeAliasType` annotations
432+
original_type = None
433+
429434
# we allow `object` as the input type because otherwise, passing things like
430435
# `Literal['value']` will be reported as a type error by type checkers
431436
type_ = cast("type[object]", type_)
432437
if is_type_alias_type(type_):
438+
original_type = type_ # type: ignore[unreachable]
433439
type_ = type_.__value__ # type: ignore[unreachable]
434440

435441
# unwrap `Annotated[T, ...]` -> `T`
@@ -446,7 +452,7 @@ def construct_type(*, value: object, type_: object) -> object:
446452

447453
if is_union(origin):
448454
try:
449-
return validate_type(type_=cast("type[object]", type_), value=value)
455+
return validate_type(type_=cast("type[object]", original_type or type_), value=value)
450456
except Exception:
451457
pass
452458

src/steel/_utils/_sync.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@
77
from typing import Any, TypeVar, Callable, Awaitable
88
from typing_extensions import ParamSpec
99

10+
import anyio
11+
import sniffio
12+
import anyio.to_thread
13+
1014
T_Retval = TypeVar("T_Retval")
1115
T_ParamSpec = ParamSpec("T_ParamSpec")
1216

1317

1418
if sys.version_info >= (3, 9):
15-
to_thread = asyncio.to_thread
19+
_asyncio_to_thread = asyncio.to_thread
1620
else:
1721
# backport of https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread
1822
# for Python 3.8 support
19-
async def to_thread(
23+
async def _asyncio_to_thread(
2024
func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
2125
) -> Any:
2226
"""Asynchronously run function *func* in a separate thread.
@@ -34,6 +38,17 @@ async def to_thread(
3438
return await loop.run_in_executor(None, func_call)
3539

3640

41+
async def to_thread(
42+
func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
43+
) -> T_Retval:
44+
if sniffio.current_async_library() == "asyncio":
45+
return await _asyncio_to_thread(func, *args, **kwargs)
46+
47+
return await anyio.to_thread.run_sync(
48+
functools.partial(func, *args, **kwargs),
49+
)
50+
51+
3752
# inspired by `asyncer`, https://github.com/tiangolo/asyncer
3853
def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
3954
"""

0 commit comments

Comments
 (0)