Skip to content

Commit c5ce19f

Browse files
committed
chore: Bump minimum Python version to 3.10
1 parent 9eab1c9 commit c5ce19f

17 files changed

+56
-341
lines changed

.github/workflows/run_code_checks.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ jobs:
1111
name: Lint check
1212
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
1313
with:
14-
python-version: '["3.9", "3.10", "3.11", "3.12", "3.13"]'
14+
python-version: '["3.10", "3.11", "3.12", "3.13"]'
1515

1616
type_check:
1717
name: Type check
1818
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
1919
with:
20-
python-version: '["3.9", "3.10", "3.11", "3.12", "3.13"]'
20+
python-version: '["3.10", "3.11", "3.12", "3.13"]'
2121

2222
unit_tests:
2323
name: Unit tests
2424
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
2525
with:
26-
python-version: '["3.9", "3.10", "3.11", "3.12", "3.13"]'
26+
python-version: '["3.10", "3.11", "3.12", "3.13"]'
2727

2828
docs_check:
2929
name: Docs check
@@ -35,4 +35,4 @@ jobs:
3535
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
3636
secrets: inherit
3737
with:
38-
python-version: '["3.9", "3.13"]'
38+
python-version: '["3.10", "3.13"]'

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Here you'll find a contributing guide to get started with development.
44

55
## Environment
66

7-
For local development, it is required to have Python 3.9 (or a later version) installed.
7+
For local development, it is required to have Python 3.10 (or a later version) installed.
88

99
We use [uv](https://docs.astral.sh/uv/) for project management. Install it and set up your IDE accordingly.
1010

docs/01_overview/02_running_actors_locally.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ In this page, you'll learn how to create and run Apify Actors locally on your co
1111

1212
## Requirements
1313

14-
The Apify SDK requires Python version 3.9 or above to run Python Actors locally.
14+
The Apify SDK requires Python version 3.10 or above to run Python Actors locally.
1515

1616
## Creating your first Actor
1717

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
id: upgrading-to-v3
3+
title: Upgrading to v3
4+
---
5+
6+
This page summarizes most of the breaking changes between Apify Python SDK v2.x and v3.0.
7+
8+
## Python version support
9+
10+
Support for Python 3.9 has been dropped. The Apify Python SDK v3.x now requires Python 3.10 or later. Make sure your environment is running a compatible version before upgrading.

pyproject.toml

Lines changed: 3 additions & 4 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 = "[email protected]" }]
1010
license = { file = "LICENSE" }
1111
readme = "README.md"
12-
requires-python = ">=3.9"
12+
requires-python = ">=3.10"
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.9",
2019
"Programming Language :: Python :: 3.10",
2120
"Programming Language :: Python :: 3.11",
2221
"Programming Language :: Python :: 3.12",
@@ -188,7 +187,7 @@ asyncio_mode = "auto"
188187
timeout = 1200
189188

190189
[tool.mypy]
191-
python_version = "3.9"
190+
python_version = "3.10"
192191
plugins = ["pydantic.mypy"]
193192
files = ["src", "tests", "docs", "website"]
194193
check_untyped_defs = true
@@ -215,7 +214,7 @@ module = [
215214
ignore_missing_imports = true
216215

217216
[tool.basedpyright]
218-
pythonVersion = "3.9"
217+
pythonVersion = "3.10"
219218
typeCheckingMode = "standard"
220219
include = ["src", "tests", "docs", "website"]
221220

src/apify/_actor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys
66
from contextlib import suppress
77
from datetime import datetime, timedelta, timezone
8-
from typing import TYPE_CHECKING, Any, Callable, Literal, TypeVar, cast, overload
8+
from typing import TYPE_CHECKING, Any, Literal, TypeVar, cast, overload
99

1010
from lazy_object_proxy import Proxy
1111
from more_itertools import flatten
@@ -39,6 +39,7 @@
3939

4040
if TYPE_CHECKING:
4141
import logging
42+
from collections.abc import Callable
4243
from types import TracebackType
4344

4445
from typing_extensions import Self

src/apify/_charging.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from dataclasses import dataclass
55
from datetime import datetime, timezone
66
from decimal import Decimal
7-
from typing import TYPE_CHECKING, Protocol, Union
7+
from typing import TYPE_CHECKING, Protocol
88

99
from pydantic import TypeAdapter
1010

@@ -23,8 +23,7 @@
2323

2424
from apify._configuration import Configuration
2525

26-
27-
run_validator: TypeAdapter[ActorRun | None] = TypeAdapter(Union[ActorRun, None])
26+
run_validator = TypeAdapter[ActorRun | None](ActorRun | None)
2827

2928

3029
@docs_group('Interfaces')

src/apify/_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from apify._utils import docs_group
1414

1515
if TYPE_CHECKING:
16-
from typing_extensions import TypeAlias
16+
from typing import TypeAlias
1717

1818

1919
@docs_group('Data structures')

src/apify/_platform_event_manager.py

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

33
import asyncio
44
from datetime import datetime
5-
from typing import TYPE_CHECKING, Annotated, Any, Literal, Union
5+
from typing import TYPE_CHECKING, Annotated, Any, Literal
66

77
import websockets.asyncio.client
88
from pydantic import BaseModel, Discriminator, Field, TypeAdapter
@@ -113,25 +113,10 @@ class UnknownEvent(BaseModel):
113113
data: Annotated[dict[str, Any], Field(default_factory=dict)]
114114

115115

116-
EventMessage = Union[
117-
PersistStateEvent,
118-
SystemInfoEvent,
119-
MigratingEvent,
120-
AbortingEvent,
121-
ExitEvent,
122-
EventWithoutData,
123-
]
124-
125-
126-
event_data_adapter: TypeAdapter[EventMessage | DeprecatedEvent | UnknownEvent] = TypeAdapter(
127-
Union[
128-
Annotated[
129-
EventMessage,
130-
Discriminator('name'),
131-
],
132-
DeprecatedEvent,
133-
UnknownEvent,
134-
]
116+
EventMessage = PersistStateEvent | SystemInfoEvent | MigratingEvent | AbortingEvent | ExitEvent | EventWithoutData
117+
118+
event_data_adapter = TypeAdapter[EventMessage | DeprecatedEvent | UnknownEvent](
119+
Annotated[EventMessage, Discriminator('name')] | DeprecatedEvent | UnknownEvent
135120
)
136121

137122

src/apify/_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import builtins
44
import sys
55
from importlib import metadata
6-
from typing import Callable, Literal
6+
from typing import TYPE_CHECKING, Literal
7+
8+
if TYPE_CHECKING:
9+
from collections.abc import Callable
710

811

912
def get_system_info() -> dict:

0 commit comments

Comments
 (0)