Skip to content

Commit 704f9a6

Browse files
renovate[bot]Mantisus
authored andcommitted
chore(deps): update dependency ruff to ~=0.15.0 (apify#1711)
1 parent ad15c3c commit 704f9a6

File tree

12 files changed

+44
-40
lines changed

12 files changed

+44
-40
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ crawlee = "crawlee._cli:cli"
9898

9999
[dependency-groups]
100100
dev = [
101+
"anyio<5.0.0",
101102
"apify_client", # For e2e tests.
102103
"build<2.0.0", # For e2e tests.
103104
"dycw-pytest-only<3.0.0",
@@ -112,7 +113,7 @@ dev = [
112113
"pytest-timeout<3.0.0",
113114
"pytest-xdist<4.0.0",
114115
"pytest<9.0.0",
115-
"ruff~=0.14.0",
116+
"ruff~=0.15.0",
116117
"setuptools", # setuptools are used by pytest, but not explicitly required
117118
"ty~=0.0.0",
118119
"types-beautifulsoup4<5.0.0",

src/crawlee/_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class Request(BaseModel):
211211

212212
user_data: Annotated[
213213
dict[str, JsonSerializable], # Internally, the model contains `UserData`, this is just for convenience
214-
Field(alias='userData', default_factory=lambda: UserData()),
214+
Field(alias='userData', default_factory=UserData),
215215
PlainValidator(user_data_adapter.validate_python),
216216
PlainSerializer(
217217
lambda instance: user_data_adapter.dump_python(

src/crawlee/_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ class HttpHeaders(RootModel, Mapping[str, str]):
6868
else:
6969
root: Annotated[
7070
dict[str, str],
71-
PlainValidator(lambda value: _normalize_headers(value)),
72-
Field(default_factory=lambda: dict[str, str]()),
71+
PlainValidator(_normalize_headers),
72+
Field(default_factory=dict),
7373
]
7474

7575
def __getitem__(self, key: str) -> str:

src/crawlee/crawlers/_abstract_http/_abstract_http_crawler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ async def extract_links(
203203
links_iterator = to_absolute_url_iterator(base_url, links_iterator, logger=context.log)
204204

205205
if robots_txt_file:
206-
skipped, links_iterator = partition(lambda url: robots_txt_file.is_allowed(url), links_iterator)
206+
skipped, links_iterator = partition(robots_txt_file.is_allowed, links_iterator)
207207
else:
208208
skipped = iter([])
209209

src/crawlee/crawlers/_basic/_basic_crawler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ async def __run_task_function(self) -> None:
13861386
request_manager = await self.get_request_manager()
13871387

13881388
request = await wait_for(
1389-
lambda: request_manager.fetch_next_request(),
1389+
request_manager.fetch_next_request,
13901390
timeout=self._internal_timeout,
13911391
timeout_message=f'Fetching next request failed after {self._internal_timeout.total_seconds()} seconds',
13921392
logger=self._logger,

src/crawlee/crawlers/_playwright/_playwright_crawler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ async def extract_links(
409409
links_iterator = to_absolute_url_iterator(base_url, links_iterator, logger=context.log)
410410

411411
if robots_txt_file:
412-
skipped, links_iterator = partition(lambda url: robots_txt_file.is_allowed(url), links_iterator)
412+
skipped, links_iterator = partition(robots_txt_file.is_allowed, links_iterator)
413413
else:
414414
skipped = iter([])
415415

src/crawlee/http_clients/_httpx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def _build_request(
272272
headers=dict(headers) if headers else None,
273273
content=payload,
274274
extensions={'crawlee_session': session if self._persist_cookies_per_session else None},
275-
timeout=timeout if timeout else httpx.USE_CLIENT_DEFAULT,
275+
timeout=timeout or httpx.USE_CLIENT_DEFAULT,
276276
)
277277

278278
def _get_client(self, proxy_url: str | None) -> httpx.AsyncClient:
@@ -329,7 +329,7 @@ def _combine_headers(self, explicit_headers: HttpHeaders | None) -> HttpHeaders
329329
)
330330
explicit_headers = explicit_headers or HttpHeaders()
331331
headers = common_headers | user_agent_header | explicit_headers
332-
return headers if headers else None
332+
return headers or None
333333

334334
@staticmethod
335335
def _is_proxy_error(error: httpx.TransportError) -> bool:

src/crawlee/sessions/_cookies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def _convert_cookie_to_dict(self, cookie: Cookie) -> CookieParam:
143143
"""
144144
cookie_dict = CookieParam(
145145
name=cookie.name,
146-
value=cookie.value if cookie.value else '',
146+
value=cookie.value or '',
147147
domain=cookie.domain,
148148
path=cookie.path,
149149
secure=cookie.secure,

src/crawlee/storage_clients/_file_system/_request_queue_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ async def _get_request_files(cls, path_to_rq: Path) -> list[Path]:
757757
await asyncio.to_thread(path_to_rq.mkdir, parents=True, exist_ok=True)
758758

759759
# List all the json files.
760-
files = await asyncio.to_thread(lambda: list(path_to_rq.glob('*.json')))
760+
files = list(await asyncio.to_thread(path_to_rq.glob, '*.json'))
761761

762762
# Filter out metadata file and non-file entries.
763763
filtered = filter(lambda request_file: request_file.is_file() and request_file.name != METADATA_FILENAME, files)

src/crawlee/storages/_storage_instance_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ class _StorageCache:
2323
"""Cache for storage instances."""
2424

2525
by_id: defaultdict[type[Storage], defaultdict[str, defaultdict[Hashable, Storage]]] = field(
26-
default_factory=lambda: defaultdict(lambda: defaultdict(lambda: defaultdict()))
26+
default_factory=lambda: defaultdict(lambda: defaultdict(defaultdict))
2727
)
2828
"""Cache for storage instances by ID. Example: by_id[Dataset]['some_id']['some_additional_cache_key']."""
2929

3030
by_name: defaultdict[type[Storage], defaultdict[str, defaultdict[Hashable, Storage]]] = field(
31-
default_factory=lambda: defaultdict(lambda: defaultdict(lambda: defaultdict()))
31+
default_factory=lambda: defaultdict(lambda: defaultdict(defaultdict))
3232
)
3333
"""Cache for storage instances by name. Example: by_name[Dataset]['some_name']['some_additional_cache_key']"""
3434

3535
by_alias: defaultdict[type[Storage], defaultdict[str, defaultdict[Hashable, Storage]]] = field(
36-
default_factory=lambda: defaultdict(lambda: defaultdict(lambda: defaultdict()))
36+
default_factory=lambda: defaultdict(lambda: defaultdict(defaultdict))
3737
)
3838
"""Cache for storage instances by alias. Example: by_alias[Dataset]['some_alias']['some_additional_cache_key']"""
3939

0 commit comments

Comments
 (0)