Skip to content

Commit cad79e3

Browse files
committed
address feedback
1 parent f1a0c59 commit cad79e3

File tree

4 files changed

+6
-23
lines changed

4 files changed

+6
-23
lines changed

pyproject.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,6 @@ warn_return_any = true
205205
warn_unreachable = true
206206
warn_unused_ignores = true
207207

208-
[[tool.mypy.overrides]]
209-
module = ['lazy_object_proxy']
210-
ignore_missing_imports = true
211-
212208
[tool.basedpyright]
213209
pythonVersion = "3.9"
214210
typeCheckingMode = "standard"

src/crawlee/service_locator.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@
66
from crawlee.errors import ServiceConflictError
77
from crawlee.events._event_manager import EventManager
88

9-
__all__ = [
10-
'get_configuration',
11-
'get_event_manager',
12-
'get_storage_client',
13-
'set_configuration',
14-
'set_event_manager',
15-
'set_storage_client',
16-
]
9+
__all__ = list[str]() # Prefer "from crawlee import service_locator"
1710

1811

1912
class _ServiceLocator:

src/crawlee/statistics/_statistics.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
if TYPE_CHECKING:
2121
from types import TracebackType
2222

23-
from crawlee.events import EventManager
24-
2523
TStatisticsState = TypeVar('TStatisticsState', bound=StatisticsState, default=StatisticsState)
2624

2725
logger = getLogger(__name__)
@@ -67,7 +65,6 @@ class Statistics(Generic[TStatisticsState]):
6765
def __init__(
6866
self,
6967
*,
70-
event_manager: EventManager | None = None,
7168
persistence_enabled: bool = False,
7269
persist_state_kvs_name: str = 'default',
7370
persist_state_key: str | None = None,
@@ -77,9 +74,6 @@ def __init__(
7774
log_interval: timedelta = timedelta(minutes=1),
7875
state_model: type[TStatisticsState] = cast(Any, StatisticsState), # noqa: B008 - in an ideal world, TStatisticsState would be inferred from this argument, but I haven't managed to do that
7976
) -> None:
80-
if event_manager:
81-
service_locator.set_event_manager(event_manager)
82-
8377
self._id = Statistics.__next_id
8478
Statistics.__next_id += 1
8579

tests/unit/basic_crawler/test_basic_crawler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import httpx
1515
import pytest
1616

17-
from crawlee import ConcurrencySettings, EnqueueStrategy, Glob, service_locator
17+
from crawlee import ConcurrencySettings, EnqueueStrategy, Glob
1818
from crawlee._request import BaseRequestData, Request
1919
from crawlee._types import BasicCrawlingContext, EnqueueLinksKwargs, HttpHeaders
2020
from crawlee.basic_crawler import BasicCrawler
@@ -796,16 +796,16 @@ async def handler(context: BasicCrawlingContext) -> None:
796796
}
797797

798798

799+
@pytest.mark.only
799800
async def test_respects_no_persist_storage() -> None:
800-
config = Configuration(persist_storage=False)
801-
service_locator.set_configuration(config)
802-
crawler = BasicCrawler()
801+
configuration = Configuration(persist_storage=False)
802+
crawler = BasicCrawler(configuration=configuration)
803803

804804
@crawler.router.default_handler
805805
async def handler(context: BasicCrawlingContext) -> None:
806806
await context.push_data({'something': 'something'})
807807

808-
datasets_path = Path(config.storage_dir) / 'datasets' / 'default'
808+
datasets_path = Path(configuration.storage_dir) / 'datasets' / 'default'
809809
assert not datasets_path.exists() or list(datasets_path.iterdir()) == []
810810

811811

0 commit comments

Comments
 (0)