Skip to content

Commit 44d118d

Browse files
committed
address feedback
1 parent ef4c901 commit 44d118d

File tree

5 files changed

+25
-23
lines changed

5 files changed

+25
-23
lines changed

docs/02_concepts/code/01_class_manual.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
async def main() -> None:
77
await Actor.init()
88

9-
# Get input
10-
actor_input = await Actor.get_input()
11-
Actor.log.info('Actor input: %s', actor_input)
9+
try:
10+
# Get input
11+
actor_input = await Actor.get_input()
12+
Actor.log.info('Actor input: %s', actor_input)
1213

13-
# Your Actor logic here
14-
data = {'message': 'Hello from Actor!', 'input': actor_input}
15-
await Actor.push_data(data)
14+
# Your Actor logic here
15+
data = {'message': 'Hello from Actor!', 'input': actor_input}
16+
await Actor.push_data(data)
1617

17-
# Set status message
18-
await Actor.set_status_message('Actor completed successfully')
18+
# Set status message
19+
await Actor.set_status_message('Actor completed successfully')
1920

20-
await Actor.exit()
21+
finally:
22+
await Actor.exit()
2123

2224

2325
if __name__ == '__main__':

docs/02_concepts/code/01_instance_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async def main() -> None:
2020
await actor.push_data(data)
2121

2222
# Set status message
23-
await Actor.set_status_message('Actor completed successfully')
23+
await actor.set_status_message('Actor completed successfully')
2424

2525

2626
if __name__ == '__main__':

docs/02_concepts/code/01_instance_manual.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@ async def main() -> None:
1212

1313
await actor.init()
1414

15-
# Get input
16-
actor_input = await actor.get_input()
17-
actor.log.info('Actor input: %s', actor_input)
15+
try:
16+
# Get input
17+
actor_input = await actor.get_input()
18+
actor.log.info('Actor input: %s', actor_input)
1819

19-
# Your Actor logic here
20-
data = {'message': 'Hello from Actor!', 'input': actor_input}
21-
await actor.push_data(data)
20+
# Your Actor logic here
21+
data = {'message': 'Hello from Actor!', 'input': actor_input}
22+
await actor.push_data(data)
2223

23-
# Set status message
24-
await actor.set_status_message('Actor completed successfully')
24+
# Set status message
25+
await actor.set_status_message('Actor completed successfully')
2526

26-
await actor.exit()
27+
finally:
28+
await actor.exit()
2729

2830

2931
if __name__ == '__main__':

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ ignore = [
113113
"PLR0911", # Too many return statements
114114
"PLR0913", # Too many arguments in function definition
115115
"PLR0915", # Too many statements
116-
"PLR2004", # Magic value used in comparison, consider replacing `0.2` with a constant variable
117116
"PTH", # flake8-use-pathlib
118117
"PYI034", # `__aenter__` methods in classes like `{name}` usually return `self` at runtime
119118
"PYI036", # The second argument in `__aexit__` should be annotated with `object` or `BaseException | None`
@@ -153,6 +152,7 @@ indent-style = "space"
153152
"INP001", # File {filename} is part of an implicit namespace package, add an __init__.py
154153
"F841", # Local variable {variable} is assigned to but never used
155154
"TRY301", # Abstract `raise` to an inner function
155+
"PLR2004", # Magic value used in comparison, consider replacing `{value}` with a constant variable
156156
"PLW0603", # Using the global statement to update `{name}` is discouraged
157157
]
158158
"**/docs/**/scrapy_project/**/__main__.py" = [

tests/integration/test_actor_lifecycle.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from typing import TYPE_CHECKING
44

5-
from apify_shared.consts import ActorExitCodes
6-
75
from apify import Actor
86

97
if TYPE_CHECKING:
@@ -117,7 +115,7 @@ async def main() -> None:
117115
actor = await make_actor(label='with-actor-fail', main_func=main)
118116
run_result = await run_actor(actor)
119117

120-
assert run_result.exit_code == ActorExitCodes.ERROR_USER_FUNCTION_THREW.value
118+
assert run_result.exit_code == 91
121119
assert run_result.status == 'FAILED'
122120

123121

0 commit comments

Comments
 (0)