Skip to content

Commit 99e3cc3

Browse files
committed
docs: use before/after code comments in v4 upgrading guide samples
1 parent dcdee59 commit 99e3cc3

1 file changed

Lines changed: 10 additions & 30 deletions

File tree

‎docs/04_upgrading/upgrading_to_v4.md‎

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,11 @@ The SDK is now built on [`apify-client`](https://docs.apify.com/api/client/pytho
5959

6060
If you imported the platform environment-variable enums from `apify_shared.consts` (`ApifyEnvVars`, `ActorEnvVars`), import them from `apify` instead — they are now vendored in the SDK and re-exported from the top-level package.
6161

62-
**Before (v3.x):**
63-
6462
```python
63+
# Before (v3)
6564
from apify_shared.consts import ApifyEnvVars
66-
```
67-
68-
**Now (v4.0):**
6965

70-
```python
66+
# After (v4)
7167
from apify import ApifyEnvVars
7268
```
7369

@@ -82,18 +78,14 @@ Generated enum-like types are now [`Literal`](https://docs.python.org/3/library/
8278
- `apify.WebhookEventType` is now a `Literal[...]` instead of a `StrEnum`. Use plain string values (`'ACTOR.RUN.FAILED'`) instead of enum members.
8379
- `apify_shared.consts.ActorEventTypes` (a `StrEnum`) is replaced by `apify.ActorEventTypes`, now a `Literal['systemInfo', 'persistState', 'migrating', 'aborting']`. For runtime values, use `apify.Event` (re-exported from Crawlee) instead of enum members.
8480

85-
**Before (v3.x):**
86-
8781
```python
82+
# Before (v3)
8883
from apify import Actor
8984
from apify_shared.consts import ActorEventTypes
9085

9186
Actor.on(ActorEventTypes.SYSTEM_INFO, callback)
92-
```
93-
94-
**Now (v4.0):**
9587

96-
```python
88+
# After (v4)
9789
from apify import Actor, Event
9890

9991
Actor.on(Event.SYSTEM_INFO, callback)
@@ -109,9 +101,8 @@ The `Webhook` model has been slimmed down to only the fields a user sets when de
109101

110102
The retry and idempotency kwargs that used to live on `Actor.add_webhook` have moved onto the `Webhook` instance itself.
111103

112-
**Before (v3.x):**
113-
114104
```python
105+
# Before (v3)
115106
from apify import Actor, Webhook
116107

117108
await Actor.add_webhook(
@@ -120,11 +111,8 @@ await Actor.add_webhook(
120111
do_not_retry=False,
121112
idempotency_key='my-key',
122113
)
123-
```
124114

125-
**Now (v4.0):**
126-
127-
```python
115+
# After (v4)
128116
from apify import Actor, Webhook
129117

130118
await Actor.add_webhook(
@@ -156,18 +144,14 @@ The `webhooks` argument on `Actor.start`, `Actor.call`, and `Actor.call_task` st
156144

157145
Direct `.get(id)` and `.delete(id)` calls still swallow 404 into `None`. But where a 404 could mean either the parent or the sub-resource is missing, the client now raises `NotFoundError` instead of returning `None`.
158146

159-
**Before (v3.x):**
160-
161147
```python
148+
# Before (v3)
162149
client = Actor.new_client()
163150

164151
# Returned None on 404.
165152
dataset = await client.run('some-run-id').dataset().get()
166-
```
167153

168-
**Now (v4.0):**
169-
170-
```python
154+
# After (v4)
171155
from apify_client.errors import NotFoundError
172156

173157
client = Actor.new_client()
@@ -183,16 +167,12 @@ except NotFoundError:
183167

184168
Secondary parameters on several client methods can no longer be passed positionally.
185169

186-
**Before (v3.x):**
187-
188170
```python
171+
# Before (v3)
189172
await client.key_value_store('my-store').set_record('my-key', {'data': 1}, 'application/json')
190173
await client.run('my-run').charge('my-event', 5)
191-
```
192174

193-
**Now (v4.0):**
194-
195-
```python
175+
# After (v4)
196176
await client.key_value_store('my-store').set_record('my-key', {'data': 1}, content_type='application/json')
197177
await client.run('my-run').charge('my-event', count=5)
198178
```

0 commit comments

Comments
 (0)