Skip to content

Commit 2f9dcc5

Browse files
authored
refactor!: Preparation for v2 release (#210)
- **Update pyproject.toml** - **Use storage code from crawlee, add ApifyStorageClient** - [x] make sure we use `APIFY_IS_AT_HOME` instead of token for all platform vs. local decisions - [x] port over `warnedAboutMissingInitCall` from JS SDK (this is not exactly ported over, but we expect this won't happen frequently, so we just throw an exception) ### Issues - Closes: #135 - Closes: #137 - Closes: #138 - Closes: #147 - Closes: #149 - Closes: #237
1 parent 3878758 commit 2f9dcc5

File tree

102 files changed

+2964
-9229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+2964
-9229
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ tests with HTML coverage report execute `make unit-tests-cov`.
5050

5151
## Integration tests
5252

53-
We have integration tests which build and run actors using the Python SDK on the Apify Platform. To run these tests,
53+
We have integration tests which build and run Actors using the Python SDK on the Apify Platform. To run these tests,
5454
you need to set the `APIFY_TEST_USER_API_TOKEN` environment variable to the API token of the Apify user you want to
5555
use for the tests, and then start them with `make integration-tests`.
5656

docs/02-guides/02-beautiful-soup.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async def main():
3636
max_depth = actor_input.get('max_depth', 1)
3737

3838
if not start_urls:
39-
Actor.log.info('No start URLs specified in actor input, exiting...')
39+
Actor.log.info('No start URLs specified in Actor input, exiting...')
4040
await Actor.exit()
4141

4242
# Enqueue the starting URLs in the default request queue

docs/02-guides/03-playwright.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ To create Actors which use Playwright, start from the [Playwright & Python](http
2929
On the Apify platform, the Actor will already have Playwright and the necessary browsers preinstalled in its Docker image,
3030
including the tools and setup necessary to run browsers in headful mode.
3131

32-
When running the Actor locally, you'll need to finish the Playwright setup yourself before you can run the actor.
32+
When running the Actor locally, you'll need to finish the Playwright setup yourself before you can run the Actor.
3333

3434
<Tabs groupId="operating-systems">
3535
<TabItem value="unix" label="Linux / macOS" default>
@@ -69,7 +69,7 @@ async def main():
6969
max_depth = actor_input.get('max_depth', 1)
7070

7171
if not start_urls:
72-
Actor.log.info('No start URLs specified in actor input, exiting...')
72+
Actor.log.info('No start URLs specified in Actor input, exiting...')
7373
await Actor.exit()
7474

7575
# Enqueue the starting URLs in the default request queue

docs/02-guides/04-selenium.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async def main():
5353
max_depth = actor_input.get('max_depth', 1)
5454

5555
if not start_urls:
56-
Actor.log.info('No start URLs specified in actor input, exiting...')
56+
Actor.log.info('No start URLs specified in Actor input, exiting...')
5757
await Actor.exit()
5858

5959
# Enqueue the starting URLs in the default request queue

docs/02-guides/05-scrapy.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class TitleSpider(scrapy.Spider):
8787
if link_url.startswith(('http://', 'https://')):
8888
yield scrapy.Request(link_url)
8989

90-
# Pushes the scraped items into the actor's default dataset
90+
# Pushes the scraped items into the Actor's default dataset
9191
class ActorDatasetPushPipeline:
9292
async def process_item(self, item, spider):
9393
item_dict = ItemAdapter(item).asdict()

docs/03-concepts/04-actor-events.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async def main():
9191
# Save the state when the `PERSIST_STATE` event happens
9292
async def save_state(event_data):
9393
nonlocal processed_items
94-
Actor.log.info('Saving actor state', extra=event_data)
94+
Actor.log.info('Saving Actor state', extra=event_data)
9595
await Actor.set_value('STATE', processed_items)
9696

9797
Actor.on(ActorEventTypes.PERSIST_STATE, save_state)

mypy.ini

Lines changed: 0 additions & 22 deletions
This file was deleted.

pyproject.toml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "apify"
3-
version = "1.7.3"
3+
version = "2.0.0"
44
description = "Apify SDK for Python"
55
readme = "README.md"
66
license = { text = "Apache Software License" }
@@ -20,7 +20,7 @@ classifiers = [
2020
"Topic :: Software Development :: Libraries",
2121
]
2222

23-
requires-python = ">=3.8"
23+
requires-python = ">=3.9"
2424

2525
# We use inclusive ordered comparison clause for non-Apify packages intentionally in order to enhance the Apify SDK's
2626
# compatibility with a wide range of external packages. This decision was discussed in detail in the following PR:
@@ -31,8 +31,10 @@ dependencies = [
3131
"aiofiles >= 22.1.0",
3232
"aioshutil >= 1.0",
3333
"colorama >= 0.4.6",
34+
"crawlee >= 0.3.0",
3435
"cryptography >= 39.0.0",
3536
"httpx >= 0.24.0",
37+
"lazy-object-proxy >= 1.10.0",
3638
"psutil >= 5.9.0",
3739
"pyee >= 11.0.0",
3840
"sortedcollections >= 2.0.0",
@@ -90,12 +92,16 @@ line-length = 150
9092
[tool.ruff.lint]
9193
select = ["ALL"]
9294
ignore = [
95+
"A002", # Argument is shadowing a Python builtin
96+
"ANN101", # Missing type annotation for `self` in method
97+
"ANN102", # Missing type annotation for `cls` in method
9398
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in {filename}
9499
"BLE001", # Do not catch blind exception
95100
"C901", # `{name}` is too complex
96101
"COM812", # This rule may cause conflicts when used with the formatter
97102
"D100", # Missing docstring in public module
98103
"D104", # Missing docstring in public package
104+
"D107", # Missing docstring in `__init__`
99105
"EM", # flake8-errmsg
100106
"G004", # Logging statement uses f-string
101107
"ISC001", # This rule may cause conflicts when used with the formatter
@@ -152,6 +158,33 @@ inline-quotes = "single"
152158

153159
[tool.ruff.lint.isort]
154160
known-local-folder = ["apify"]
161+
known-first-party = ["apify_client", "apify_shared", "crawlee"]
155162

156163
[tool.ruff.lint.pydocstyle]
157164
convention = "google"
165+
166+
[tool.basedpyright]
167+
typeCheckingMode = "standard"
168+
169+
[tool.pytest.ini_options]
170+
asyncio_mode = "auto"
171+
timeout = 1200
172+
173+
[tool.mypy]
174+
python_version = "3.9"
175+
plugins = ["pydantic.mypy"]
176+
files = ["scripts", "src", "tests"]
177+
check_untyped_defs = true
178+
disallow_incomplete_defs = true
179+
disallow_untyped_calls = true
180+
disallow_untyped_decorators = true
181+
disallow_untyped_defs = true
182+
no_implicit_optional = true
183+
warn_redundant_casts = true
184+
warn_return_any = true
185+
warn_unreachable = true
186+
warn_unused_ignores = true
187+
188+
[[tool.mypy.overrides]]
189+
module = ['scrapy', 'scrapy.*', 'sortedcollections', 'lazy_object_proxy']
190+
ignore_missing_imports = true

pytest.ini

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/apify/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from importlib import metadata
22

3-
from .actor import Actor
4-
from .config import Configuration
5-
from .proxy_configuration import ProxyConfiguration, ProxyInfo
3+
from crawlee.events._types import Event
4+
5+
from apify._actor import Actor
6+
from apify._configuration import Configuration
7+
from apify._proxy_configuration import ProxyConfiguration, ProxyInfo
68

79
__version__ = metadata.version('apify')
810

9-
__all__ = ['Actor', 'Configuration', 'ProxyConfiguration', 'ProxyInfo', '__version__']
11+
__all__ = ['Actor', 'Event', 'Configuration', 'ProxyConfiguration', 'ProxyInfo', '__version__']

0 commit comments

Comments
 (0)