Skip to content

Commit a67788e

Browse files
authored
chore!: drop Python 3.10 support (#908)
## Issue - Closes: #757 ## Summary - Bump the minimum supported Python to **3.11** in `pyproject.toml` (`requires-python`, classifiers, `[tool.ty.environment]`) and drop 3.10 from every CI matrix in `.github/workflows/_checks.yaml` (lint, type-check, unit tests, integration tests, e2e tests). - Apply ruff autofixes unlocked by the version bump across `src/` and `tests/`: `UP017` (`datetime.timezone.utc` → `datetime.UTC`), `UP035` (`typing_extensions.Self` → `typing.Self`), `UP041` (`asyncio.TimeoutError` → builtin `TimeoutError`). - Refresh `uv.lock` — the resolver drops the 3.10-only backport packages (`backports-asyncio-runner`, `exceptiongroup`, `importlib-metadata`, `zipp`). ## Why 3.10 reaches end-of-life soon, and the upcoming `apify-client` v3 already requires `>=3.11`. Landing the version drop on its own first keeps the v3 client-upgrade series small and reviewable. ## BREAKING CHANGE Python 3.10 is no longer supported. Users on 3.10 must upgrade to 3.11+ before pulling the next SDK release.
1 parent c0b17ff commit a67788e

19 files changed

Lines changed: 54 additions & 331 deletions

‎.github/workflows/_checks.yaml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,21 @@ jobs:
4545
name: Lint check
4646
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
4747
with:
48-
python_versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
48+
python_versions: '["3.11", "3.12", "3.13", "3.14"]'
4949

5050
type_check:
5151
name: Type check
5252
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
5353
with:
54-
python_versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
54+
python_versions: '["3.11", "3.12", "3.13", "3.14"]'
5555

5656
unit_tests:
5757
name: Unit tests
5858
if: inputs.run_tests
5959
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
6060
secrets: inherit
6161
with:
62-
python_versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
62+
python_versions: '["3.11", "3.12", "3.13", "3.14"]'
6363
operating_systems: '["ubuntu-latest", "windows-latest"]'
6464
python_version_for_codecov: "3.14"
6565
operating_system_for_codecov: ubuntu-latest
@@ -80,7 +80,7 @@ jobs:
8080
strategy:
8181
matrix:
8282
os: ["ubuntu-latest"]
83-
python-version: ["3.10", "3.14"]
83+
python-version: ["3.11", "3.14"]
8484

8585
runs-on: ${{ matrix.os }}
8686

@@ -140,7 +140,7 @@ jobs:
140140
strategy:
141141
matrix:
142142
os: ["ubuntu-latest"]
143-
python-version: ["3.10", "3.14"]
143+
python-version: ["3.11", "3.14"]
144144

145145
runs-on: ${{ matrix.os }}
146146

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
id: upgrading-to-v4
3+
title: Upgrading to v4
4+
description: Breaking changes and migration guide from Apify SDK v3.x to v4.0.
5+
---
6+
7+
This guide lists the breaking changes between Apify Python SDK v3.x and v4.0.
8+
9+
## Python 3.11+ required
10+
11+
Support for Python 3.10 has been dropped. The Apify Python SDK v4.x now requires Python 3.11 or later. Make sure your environment is on a compatible version before upgrading.

‎pyproject.toml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ description = "Apify SDK for Python"
99
authors = [{ name = "Apify Technologies s.r.o.", email = "support@apify.com" }]
1010
license = { file = "LICENSE" }
1111
readme = "README.md"
12-
requires-python = ">=3.10"
12+
requires-python = ">=3.11"
1313
classifiers = [
1414
"Development Status :: 5 - Production/Stable",
1515
"Environment :: Console",
1616
"Intended Audience :: Developers",
1717
"License :: OSI Approved :: Apache Software License",
1818
"Operating System :: OS Independent",
19-
"Programming Language :: Python :: 3.10",
2019
"Programming Language :: Python :: 3.11",
2120
"Programming Language :: Python :: 3.12",
2221
"Programming Language :: Python :: 3.13",
@@ -210,7 +209,7 @@ asyncio_mode = "auto"
210209
timeout = 1800
211210

212211
[tool.ty.environment]
213-
python-version = "3.10"
212+
python-version = "3.11"
214213

215214
[tool.ty.src]
216215
include = ["src", "tests", "scripts", "docs", "website"]

‎src/apify/_actor.py‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55
import warnings
66
from contextlib import suppress
7-
from datetime import datetime, timedelta, timezone
7+
from datetime import UTC, datetime, timedelta
88
from functools import cached_property
99
from typing import TYPE_CHECKING, Any, Literal, TypeVar, cast, overload
1010

@@ -44,8 +44,7 @@
4444
from collections.abc import Callable, MutableMapping
4545
from decimal import Decimal
4646
from types import TracebackType
47-
48-
from typing_extensions import Self
47+
from typing import Self
4948

5049
from apify_shared.consts import ActorPermissionLevel
5150
from crawlee._types import JsonSerializable
@@ -1241,7 +1240,7 @@ async def reboot(
12411240
),
12421241
timeout=event_listeners_timeout.total_seconds() if event_listeners_timeout else None,
12431242
)
1244-
except asyncio.TimeoutError:
1243+
except TimeoutError:
12451244
self.log.warning('Pre-reboot event listeners did not finish within timeout; proceeding with reboot')
12461245
results = []
12471246

@@ -1442,7 +1441,7 @@ def _get_default_exit_process(self) -> bool:
14421441
def _get_remaining_time(self) -> timedelta | None:
14431442
"""Get time remaining from the Actor timeout. Returns `None` if not on an Apify platform."""
14441443
if self.is_at_home() and self.configuration.timeout_at:
1445-
return max(self.configuration.timeout_at - datetime.now(tz=timezone.utc), timedelta(0))
1444+
return max(self.configuration.timeout_at - datetime.now(tz=UTC), timedelta(0))
14461445

14471446
self.log.warning(
14481447
'Using `inherit` or `RemainingTime` argument is only possible when the Actor'

‎src/apify/_charging.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import math
44
from contextvars import ContextVar
55
from dataclasses import dataclass
6-
from datetime import datetime, timezone
6+
from datetime import UTC, datetime
77
from decimal import Decimal
88
from typing import TYPE_CHECKING, Protocol, TypedDict
99

@@ -320,7 +320,7 @@ async def charge(self, event_name: str, count: int = 1) -> ChargeResult:
320320
'event_title': pricing_info.title,
321321
'event_price_usd': float(round(pricing_info.price, 3)),
322322
'charged_count': charged_count,
323-
'timestamp': datetime.now(timezone.utc).isoformat(),
323+
'timestamp': datetime.now(UTC).isoformat(),
324324
}
325325
)
326326

‎src/apify/_configuration.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
from decimal import Decimal
66
from logging import getLogger
77
from pathlib import Path
8-
from typing import Annotated, Any
8+
from typing import Annotated, Any, Self
99

1010
from pydantic import AliasChoices, BeforeValidator, Field, model_validator
11-
from typing_extensions import Self, TypedDict, deprecated
11+
from typing_extensions import TypedDict, deprecated
1212

1313
from crawlee import service_locator
1414
from crawlee._utils.models import timedelta_ms

‎src/apify/events/_apify_event_manager.py‎

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

33
import asyncio
44
import contextlib
5-
from typing import TYPE_CHECKING, Annotated
5+
from typing import TYPE_CHECKING, Annotated, Self
66

77
import websockets.asyncio.client
88
from pydantic import Discriminator, TypeAdapter
9-
from typing_extensions import Self, Unpack, override
9+
from typing_extensions import Unpack, override
1010

1111
from crawlee.events import EventManager
1212
from crawlee.events._types import Event, EventPersistStateData

‎src/apify/storage_clients/_apify/_request_queue_shared_client.py‎

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

33
import asyncio
44
from collections import deque
5-
from datetime import datetime, timedelta, timezone
5+
from datetime import UTC, datetime, timedelta
66
from logging import getLogger
77
from typing import TYPE_CHECKING, Any, Final
88

@@ -214,7 +214,7 @@ async def mark_request_as_handled(self, request: Request) -> ProcessedRequest |
214214
request_id = unique_key_to_request_id(request.unique_key)
215215
# Set the handled_at timestamp if not already set
216216
if request.handled_at is None:
217-
request.handled_at = datetime.now(tz=timezone.utc)
217+
request.handled_at = datetime.now(tz=UTC)
218218

219219
if cached_request := self._requests_cache.get(request_id):
220220
cached_request.was_already_handled = request.was_already_handled

‎src/apify/storage_clients/_apify/_request_queue_single_client.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from collections import deque
4-
from datetime import datetime, timezone
4+
from datetime import UTC, datetime
55
from logging import getLogger
66
from typing import TYPE_CHECKING, Final
77

@@ -212,7 +212,7 @@ async def mark_request_as_handled(self, request: Request) -> ProcessedRequest |
212212
cached_request.handled_at = request.handled_at
213213

214214
if request.handled_at is None:
215-
request.handled_at = datetime.now(tz=timezone.utc)
215+
request.handled_at = datetime.now(tz=UTC)
216216
self.metadata.handled_request_count += 1
217217
self.metadata.pending_request_count -= 1
218218

‎src/apify/storage_clients/_file_system/_dataset_client.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Any
3+
from typing import TYPE_CHECKING, Any, Self
44

5-
from typing_extensions import Self, override
5+
from typing_extensions import override
66

77
from crawlee.storage_clients._file_system import FileSystemDatasetClient
88

0 commit comments

Comments
 (0)