Skip to content

Commit c26c39a

Browse files
authored
chore: Downgrade to Python 3.11 for our internal PyPI (#177)
1 parent 003bf71 commit c26c39a

File tree

6 files changed

+100
-10
lines changed

6 files changed

+100
-10
lines changed

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.13.1
1+
3.11

clients/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ authors = [
99
homepage = "https://getsentry.github.io/objectstore/"
1010
repository = "https://github.com/getsentry/objectstore"
1111
license = { file = "LICENSE.md" }
12-
requires-python = ">=3.13"
12+
requires-python = ">=3.11"
1313
dependencies = [
1414
"sentry-sdk>=2.42.1",
1515
"urllib3>=2.5.0",

clients/python/src/objectstore_client/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(
5858
# We define both as 500ms which is still very conservative,
5959
# given that we are in the same network,
6060
# and expect our backends to respond in <100ms.
61-
self._timeout = timeout or urllib3.Timeout(connect=0.5, read=0.5)
61+
self._timeout = timeout or urllib3.Timeout(connect=0.5, read=0.5)
6262

6363
self._default_compression: Compression = "zstd"
6464
self._default_expiration_policy = (

clients/python/src/objectstore_client/metadata.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import itertools
44
import re
5-
from collections.abc import Mapping
5+
from collections.abc import Iterable, Iterator, Mapping
66
from dataclasses import dataclass
77
from datetime import timedelta
8-
from typing import Literal, cast
8+
from typing import Literal, TypeVar, cast
99

1010
Compression = Literal["zstd"]
1111

@@ -92,7 +92,7 @@ def parse_timedelta(delta: str) -> timedelta:
9292
words = TIME_SPLIT.findall(delta)
9393
seconds = 0
9494

95-
for num, unit in itertools.batched(words, n=2, strict=True):
95+
for num, unit in itertools_batched(words, n=2, strict=True):
9696
num = int(num)
9797
multiplier = 0
9898

@@ -110,3 +110,28 @@ def parse_timedelta(delta: str) -> timedelta:
110110
seconds += num * multiplier
111111

112112
return timedelta(seconds=seconds)
113+
114+
115+
T = TypeVar("T")
116+
117+
118+
def itertools_batched(
119+
iterable: Iterable[T], n: int, strict: bool = False
120+
) -> Iterator[tuple[T, ...]]:
121+
"""
122+
Vendored version of `itertools.batched`, not available in Python 3.11.
123+
Batch data from the iterable into tuples of length n.
124+
The last batch may be shorter than n.
125+
If strict is true, will raise a ValueError if the final batch is shorter than n.
126+
Loops over the input iterable and accumulates data into tuples up to size n.
127+
The input is consumed lazily, just enough to fill a batch.
128+
The result is yielded as soon as the batch is full
129+
or when the input iterable is exhausted:
130+
"""
131+
if n < 1:
132+
raise ValueError("n must be at least one")
133+
iterator = iter(iterable)
134+
while batch := tuple(itertools.islice(iterator, n)):
135+
if strict and len(batch) < n:
136+
raise ValueError("final batch is shorter than n")
137+
yield batch

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "objectstore"
3-
version = "0.1.0"
4-
requires-python = ">=3.13"
3+
version = "0.0.0"
4+
requires-python = ">=3.11"
55

66
[tool.uv]
77
required-version = "==0.9.3" # keep in sync with devenv/config.ini

0 commit comments

Comments
 (0)