Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ keywords = [
"Issue Tracker" = "https://github.com/apify/apify-sdk-python/issues"
"Repository" = "https://github.com/apify/apify-sdk-python"

# We use inclusive ordered comparison clauses for external packages intentionally in order to enhance SDK's
# compatibility with external packages. This decision was discussed in detail in the following PR:
# https://github.com/apify/apify-sdk-python/pull/154.
[tool.poetry.dependencies]
python = "^3.9"
apify-client = ">=1.8.1"
Expand Down Expand Up @@ -94,7 +91,6 @@ ignore = [
"G004", # Logging statement uses f-string
"ISC001", # This rule may cause conflicts when used with the formatter
"FIX", # flake8-fixme
"PGH003", # Use specific rule codes when ignoring type issues
"PLR0911", # Too many return statements
"PLR0913", # Too many arguments in function definition
"PLR0915", # Too many statements
Expand Down Expand Up @@ -184,15 +180,17 @@ exclude = []
module = ['scrapy', 'scrapy.*', 'lazy_object_proxy']
ignore_missing_imports = true

[tool.basedpyright]
pythonVersion = "3.9"
typeCheckingMode = "standard"
include = ["src", "tests"]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
"assert_never()",
]

[tool.basedpyright]
typeCheckingMode = "standard"

[tool.ipdb]
context = 7
2 changes: 1 addition & 1 deletion src/apify/_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,4 @@ class Configuration(CrawleeConfiguration):


# Monkey-patch the base class so that it works with the extended configuration
CrawleeConfiguration.get_global_configuration = Configuration.get_global_configuration # type: ignore
CrawleeConfiguration.get_global_configuration = Configuration.get_global_configuration # type: ignore[method-assign]
3 changes: 2 additions & 1 deletion tests/integration/test_actor_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ async def test_event_listener_can_be_removed_successfully(
) -> None:
async def main() -> None:
import os
from typing import Any

from apify_shared.consts import ApifyEnvVars
from crawlee.events._types import Event
Expand All @@ -85,7 +86,7 @@ async def main() -> None:

counter = 0

def count_event(data): # type: ignore # noqa: ANN202, ANN001
def count_event(data: Any) -> None:
nonlocal counter
print(data)
counter += 1
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/actor/test_actor_create_proxy_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async def test_basic_proxy_configuration_creation(
assert proxy_configuration._password == DUMMY_PASSWORD
assert proxy_configuration._country_code == country_code

assert len(patched_apify_client.calls['user']['get']) == 1 # type: ignore
assert len(patched_apify_client.calls['user']['get']) == 1 # type: ignore[attr-defined]
assert len(route.calls) == 1

await Actor.exit()
Expand Down Expand Up @@ -137,7 +137,7 @@ async def test_proxy_configuration_with_actor_proxy_input(
== f'http://groups-{"+".join(groups)},country-{country_code}:{DUMMY_PASSWORD}@proxy.apify.com:8000'
)

assert len(patched_apify_client.calls['user']['get']) == 2 # type: ignore
assert len(patched_apify_client.calls['user']['get']) == 2 # type: ignore[attr-defined]
assert len(route.calls) == 2

await Actor.exit()
2 changes: 1 addition & 1 deletion tests/unit/actor/test_actor_env_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async def test_get_env_with_randomized_env_vars(monkeypatch: pytest.MonkeyPatch)
continue

datetime_get_env_var = datetime_env_var.name.lower()
expected_get_env[datetime_get_env_var] = datetime.now(TzInfo(0)) # type: ignore
expected_get_env[datetime_get_env_var] = datetime.now(TzInfo(0)) # type: ignore[call-arg]
monkeypatch.setenv(
datetime_env_var,
expected_get_env[datetime_get_env_var].strftime('%Y-%m-%dT%H:%M:%S.%fZ'),
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/scrapy/middlewares/test_apify_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,5 @@ def test_handles_exceptions(
dummy_request: Request,
exception: Exception,
) -> None:
returned_value = middleware.process_exception(dummy_request, exception, spider) # type: ignore
returned_value = middleware.process_exception(dummy_request, exception, spider) # type: ignore[func-returns-value]
assert returned_value is None
10 changes: 5 additions & 5 deletions tests/unit/test_proxy_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ def test_invalid_arguments() -> None:
(['abc', 'DEF', 'geh$'], 2),
([111, 'DEF', 'geh$'], 2),
]:
with pytest.raises(ValueError, match=re.escape(str(invalid_groups[bad_group_index]))): # type: ignore
ProxyConfiguration(groups=invalid_groups) # type: ignore
with pytest.raises(ValueError, match=re.escape(str(invalid_groups[bad_group_index]))): # type: ignore[index]
ProxyConfiguration(groups=invalid_groups) # type: ignore[arg-type]

for invalid_country_code in ['CZE', 'aa', 'DDDD', 1111]:
with pytest.raises(ValueError, match=re.escape(str(invalid_country_code))):
ProxyConfiguration(country_code=invalid_country_code) # type: ignore
ProxyConfiguration(country_code=invalid_country_code) # type: ignore[arg-type]

with pytest.raises(ValueError, match='Exactly one of .* must be specified'):
ProxyConfiguration(
Expand Down Expand Up @@ -402,7 +402,7 @@ async def test_initialize_with_valid_configuration(
assert proxy_configuration._password == DUMMY_PASSWORD
assert proxy_configuration.is_man_in_the_middle is True

assert len(patched_apify_client.calls['user']['get']) == 1 # type: ignore
assert len(patched_apify_client.calls['user']['get']) == 1 # type: ignore[attr-defined]
assert len(route.calls) == 1


Expand Down Expand Up @@ -526,7 +526,7 @@ async def test_initialize_with_non_apify_proxy(

await proxy_configuration.initialize()

assert len(patched_apify_client.calls['user']['get']) == 0 # type: ignore
assert len(patched_apify_client.calls['user']['get']) == 0 # type: ignore[attr-defined]
assert len(route.calls) == 0


Expand Down
Loading