Skip to content

Commit dcf2485

Browse files
authored
chore: update Ruff to 0.8 (#738)
1 parent d5082d0 commit dcf2485

35 files changed

+294
-234
lines changed

poetry.lock

Lines changed: 159 additions & 164 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pytest-only = "~2.1.0"
8484
pytest-timeout = "~2.3.0"
8585
pytest-xdist = "~3.6.0"
8686
respx = "~0.21.0"
87-
ruff = "~0.7.0"
87+
ruff = "~0.8.0"
8888
setuptools = "~75.6.0" # setuptools are used by pytest, but not explicitly required
8989
sortedcontainers-stubs = "^2.4.2"
9090
types-beautifulsoup4 = "~4.12.0.20240229"
@@ -109,8 +109,6 @@ line-length = 120
109109
[tool.ruff.lint]
110110
select = ["ALL"]
111111
ignore = [
112-
"ANN101", # Missing type annotation for `self` in method
113-
"ANN102", # Missing type annotation for `{name}` in classmethod
114112
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in {filename}
115113
"ASYNC109", # Async function definition with a `timeout` parameter
116114
"BLE001", # Do not catch blind exception
@@ -158,18 +156,21 @@ indent-style = "space"
158156
"TRY301", # Abstract `raise` to an inner function
159157
]
160158
"**/{docs}/**" = [
161-
"D", # Everything from the pydocstyle
162-
"INP001", # File {filename} is part of an implicit namespace package, add an __init__.py
163-
"F841", # Local variable {variable} is assigned to but never used
164-
"N999", # Invalid module name
159+
"D", # Everything from the pydocstyle
160+
"INP001", # File {filename} is part of an implicit namespace package, add an __init__.py
161+
"F841", # Local variable {variable} is assigned to but never used
162+
"N999", # Invalid module name
165163
]
166164

167165
[tool.ruff.lint.flake8-quotes]
168166
docstring-quotes = "double"
169167
inline-quotes = "single"
170168

171169
[tool.ruff.lint.flake8-type-checking]
172-
runtime-evaluated-base-classes = ["pydantic.BaseModel", "pydantic_settings.BaseSettings"]
170+
runtime-evaluated-base-classes = [
171+
"pydantic.BaseModel",
172+
"pydantic_settings.BaseSettings",
173+
]
173174

174175
[tool.ruff.lint.flake8-builtins]
175176
builtins-ignorelist = ["id"]
@@ -217,7 +218,7 @@ ignore_missing_imports = true
217218
exclude_lines = [
218219
"pragma: no cover",
219220
"if TYPE_CHECKING:",
220-
"assert_never()"
221+
"assert_never()",
221222
]
222223

223224
[tool.basedpyright]

src/crawlee/_autoscaling/autoscaled_pool.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
from contextlib import suppress
88
from datetime import timedelta
99
from logging import getLogger
10-
from typing import TYPE_CHECKING, Awaitable, Callable
10+
from typing import TYPE_CHECKING, Callable
1111

1212
from crawlee._types import ConcurrencySettings
1313
from crawlee._utils.docs import docs_group
1414
from crawlee._utils.recurring_task import RecurringTask
1515

1616
if TYPE_CHECKING:
17+
from collections.abc import Awaitable
18+
1719
from crawlee._autoscaling import SystemStatus
1820

1921
logger = getLogger(__name__)

src/crawlee/_utils/lru_cache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from __future__ import annotations
22

33
from collections import OrderedDict
4-
from collections.abc import MutableMapping
5-
from typing import Generic, ItemsView, Iterator, TypeVar, ValuesView
6-
from typing import OrderedDict as OrderedDictType
4+
from collections import OrderedDict as OrderedDictType
5+
from collections.abc import ItemsView, Iterator, MutableMapping, ValuesView
6+
from typing import Generic, TypeVar
77

88
T = TypeVar('T')
99

src/crawlee/_utils/measure_time.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import time
44
from contextlib import contextmanager
55
from dataclasses import dataclass
6-
from typing import Iterator
6+
from typing import TYPE_CHECKING
7+
8+
if TYPE_CHECKING:
9+
from collections.abc import Iterator
710

811

912
@dataclass

src/crawlee/base_storage_client/_base_dataset_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from __future__ import annotations
22

33
from abc import ABC, abstractmethod
4-
from typing import TYPE_CHECKING, AsyncContextManager, AsyncIterator
4+
from typing import TYPE_CHECKING
55

66
from crawlee._utils.docs import docs_group
77

88
if TYPE_CHECKING:
9+
from collections.abc import AsyncIterator
10+
from contextlib import AbstractAsyncContextManager
11+
912
from httpx import Response
1013

1114
from crawlee._types import JsonSerializable
@@ -195,7 +198,7 @@ async def stream_items(
195198
skip_hidden: bool = False,
196199
xml_root: str | None = None,
197200
xml_row: str | None = None,
198-
) -> AsyncContextManager[Response | None]:
201+
) -> AbstractAsyncContextManager[Response | None]:
199202
"""Retrieves dataset items as a streaming response.
200203
201204
Args:

src/crawlee/base_storage_client/_base_key_value_store_client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from __future__ import annotations
22

33
from abc import ABC, abstractmethod
4-
from typing import TYPE_CHECKING, Any, AsyncContextManager
4+
from typing import TYPE_CHECKING, Any
55

66
from crawlee._utils.docs import docs_group
77

88
if TYPE_CHECKING:
9+
from contextlib import AbstractAsyncContextManager
10+
911
from httpx import Response
1012

1113
from crawlee.base_storage_client._models import (
@@ -90,7 +92,7 @@ async def get_record_as_bytes(self, key: str) -> KeyValueStoreRecord[bytes] | No
9092
"""
9193

9294
@abstractmethod
93-
async def stream_record(self, key: str) -> AsyncContextManager[KeyValueStoreRecord[Response] | None]:
95+
async def stream_record(self, key: str) -> AbstractAsyncContextManager[KeyValueStoreRecord[Response] | None]:
9496
"""Retrieve the given record from the key-value store, as a stream.
9597
9698
Args:

src/crawlee/basic_crawler/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
from ._basic_crawler import BasicCrawler, BasicCrawlerOptions
44
from ._context_pipeline import ContextPipeline
55

6-
__all__ = ['BasicCrawler', 'BasicCrawlingContext', 'BasicCrawlerOptions', 'ContextPipeline']
6+
__all__ = ['BasicCrawler', 'BasicCrawlerOptions', 'BasicCrawlingContext', 'ContextPipeline']

src/crawlee/basic_crawler/_basic_crawler.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from datetime import timedelta
1313
from functools import partial
1414
from pathlib import Path
15-
from typing import TYPE_CHECKING, Any, AsyncContextManager, Callable, Generic, Union, cast
15+
from typing import TYPE_CHECKING, Any, Callable, Generic, Union, cast
1616
from urllib.parse import ParseResult, urlparse
1717

1818
from tldextract import TLDExtract
@@ -47,6 +47,7 @@
4747

4848
if TYPE_CHECKING:
4949
import re
50+
from contextlib import AbstractAsyncContextManager
5051

5152
from crawlee._types import ConcurrencySettings, HttpMethod, JsonSerializable
5253
from crawlee.base_storage_client._models import DatasetItemsListPage
@@ -130,7 +131,7 @@ class BasicCrawlerOptions(TypedDict, Generic[TCrawlingContext]):
130131
"""Enables extending the request lifecycle and modifying the crawling context. Intended for use by
131132
subclasses rather than direct instantiation of `BasicCrawler`."""
132133

133-
_additional_context_managers: NotRequired[Sequence[AsyncContextManager]]
134+
_additional_context_managers: NotRequired[Sequence[AbstractAsyncContextManager]]
134135
"""Additional context managers used throughout the crawler lifecycle."""
135136

136137
_logger: NotRequired[logging.Logger]
@@ -183,7 +184,7 @@ def __init__(
183184
configure_logging: bool = True,
184185
max_crawl_depth: int | None = None,
185186
_context_pipeline: ContextPipeline[TCrawlingContext] | None = None,
186-
_additional_context_managers: Sequence[AsyncContextManager] | None = None,
187+
_additional_context_managers: Sequence[AbstractAsyncContextManager] | None = None,
187188
_logger: logging.Logger | None = None,
188189
) -> None:
189190
"""A default constructor.

src/crawlee/basic_crawler/_context_pipeline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

3-
from typing import Any, AsyncGenerator, Awaitable, Callable, Generator, Generic, cast
3+
from collections.abc import AsyncGenerator, Awaitable, Generator
4+
from typing import Any, Callable, Generic, cast
45

56
from typing_extensions import TypeVar
67

0 commit comments

Comments
 (0)