Skip to content

Commit d0d2518

Browse files
committed
Fix mypy - docs groups
1 parent de429dc commit d0d2518

File tree

11 files changed

+52
-34
lines changed

11 files changed

+52
-34
lines changed

src/apify/_actor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555

5656
@docs_name('Actor')
57-
@docs_group('Classes')
57+
@docs_group('Actor')
5858
class _ActorType:
5959
"""The class of `Actor`. Only make a new instance if you're absolutely sure you need to."""
6060

src/apify/_charging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
run_validator = TypeAdapter[ActorRun | None](ActorRun | None)
2727

2828

29-
@docs_group('Interfaces')
29+
@docs_group('Charging')
3030
class ChargingManager(Protocol):
3131
"""Provides fine-grained access to pay-per-event functionality."""
3232

@@ -57,7 +57,7 @@ def get_pricing_info(self) -> ActorPricingInfo:
5757
"""
5858

5959

60-
@docs_group('Data structures')
60+
@docs_group('Charging')
6161
@dataclass(frozen=True)
6262
class ChargeResult:
6363
"""Result of the `ChargingManager.charge` method."""
@@ -72,7 +72,7 @@ class ChargeResult:
7272
"""How many events of each known type can still be charged within the limit."""
7373

7474

75-
@docs_group('Data structures')
75+
@docs_group('Charging')
7676
@dataclass
7777
class ActorPricingInfo:
7878
"""Result of the `ChargingManager.get_pricing_info` method."""

src/apify/_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _transform_to_list(value: Any) -> list[str] | None:
2525
return value if isinstance(value, list) else str(value).split(',')
2626

2727

28-
@docs_group('Classes')
28+
@docs_group('Configuration')
2929
class Configuration(CrawleeConfiguration):
3030
"""A class for specifying the configuration of an Actor.
3131

src/apify/_models.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from typing import TypeAlias
1717

1818

19-
@docs_group('Data structures')
19+
@docs_group('Other')
2020
class Webhook(BaseModel):
2121
__model_config__ = ConfigDict(populate_by_name=True)
2222

@@ -35,14 +35,14 @@ class Webhook(BaseModel):
3535
] = None
3636

3737

38-
@docs_group('Data structures')
38+
@docs_group('Actor')
3939
class ActorRunMeta(BaseModel):
4040
__model_config__ = ConfigDict(populate_by_name=True)
4141

4242
origin: Annotated[MetaOrigin, Field()]
4343

4444

45-
@docs_group('Data structures')
45+
@docs_group('Actor')
4646
class ActorRunStats(BaseModel):
4747
__model_config__ = ConfigDict(populate_by_name=True)
4848

@@ -63,7 +63,7 @@ class ActorRunStats(BaseModel):
6363
compute_units: Annotated[float, Field(alias='computeUnits')]
6464

6565

66-
@docs_group('Data structures')
66+
@docs_group('Actor')
6767
class ActorRunOptions(BaseModel):
6868
__model_config__ = ConfigDict(populate_by_name=True)
6969

@@ -74,7 +74,7 @@ class ActorRunOptions(BaseModel):
7474
max_total_charge_usd: Annotated[Decimal | None, Field(alias='maxTotalChargeUsd')] = None
7575

7676

77-
@docs_group('Data structures')
77+
@docs_group('Actor')
7878
class ActorRunUsage(BaseModel):
7979
__model_config__ = ConfigDict(populate_by_name=True)
8080

@@ -92,7 +92,7 @@ class ActorRunUsage(BaseModel):
9292
proxy_serps: Annotated[float | None, Field(alias='PROXY_SERPS')] = None
9393

9494

95-
@docs_group('Data structures')
95+
@docs_group('Actor')
9696
class ActorRun(BaseModel):
9797
__model_config__ = ConfigDict(populate_by_name=True)
9898

src/apify/_platform_event_manager.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
__all__ = ['EventManager', 'LocalEventManager', 'PlatformEventManager']
3232

3333

34-
@docs_group('Data structures')
34+
@docs_group('Event data')
3535
class PersistStateEvent(BaseModel):
3636
name: Literal[Event.PERSIST_STATE]
3737
data: Annotated[EventPersistStateData, Field(default_factory=lambda: EventPersistStateData(is_migrating=False))]
3838

3939

40-
@docs_group('Data structures')
40+
@docs_group('Event data')
4141
class SystemInfoEventData(BaseModel):
4242
mem_avg_bytes: Annotated[float, Field(alias='memAvgBytes')]
4343
mem_current_bytes: Annotated[float, Field(alias='memCurrentBytes')]
@@ -64,31 +64,31 @@ def to_crawlee_format(self, dedicated_cpus: float) -> EventSystemInfoData:
6464
)
6565

6666

67-
@docs_group('Data structures')
67+
@docs_group('Event data')
6868
class SystemInfoEvent(BaseModel):
6969
name: Literal[Event.SYSTEM_INFO]
7070
data: SystemInfoEventData
7171

7272

73-
@docs_group('Data structures')
73+
@docs_group('Event data')
7474
class MigratingEvent(BaseModel):
7575
name: Literal[Event.MIGRATING]
7676
data: Annotated[EventMigratingData, Field(default_factory=EventMigratingData)]
7777

7878

79-
@docs_group('Data structures')
79+
@docs_group('Event data')
8080
class AbortingEvent(BaseModel):
8181
name: Literal[Event.ABORTING]
8282
data: Annotated[EventAbortingData, Field(default_factory=EventAbortingData)]
8383

8484

85-
@docs_group('Data structures')
85+
@docs_group('Event data')
8686
class ExitEvent(BaseModel):
8787
name: Literal[Event.EXIT]
8888
data: Annotated[EventExitData, Field(default_factory=EventExitData)]
8989

9090

91-
@docs_group('Data structures')
91+
@docs_group('Event data')
9292
class EventWithoutData(BaseModel):
9393
name: Literal[
9494
Event.SESSION_RETIRED,
@@ -101,13 +101,13 @@ class EventWithoutData(BaseModel):
101101
data: Any = None
102102

103103

104-
@docs_group('Data structures')
104+
@docs_group('Event data')
105105
class DeprecatedEvent(BaseModel):
106106
name: Literal['cpuInfo']
107107
data: Annotated[dict[str, Any], Field(default_factory=dict)]
108108

109109

110-
@docs_group('Data structures')
110+
@docs_group('Event data')
111111
class UnknownEvent(BaseModel):
112112
name: str
113113
data: Annotated[dict[str, Any], Field(default_factory=dict)]
@@ -120,7 +120,7 @@ class UnknownEvent(BaseModel):
120120
)
121121

122122

123-
@docs_group('Classes')
123+
@docs_group('Event managers')
124124
class PlatformEventManager(EventManager):
125125
"""A class for managing Actor events.
126126

src/apify/_proxy_configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _check(
7070
raise ValueError(f'{error_str} does not match pattern {pattern.pattern!r}')
7171

7272

73-
@docs_group('Classes')
73+
@docs_group('Configuration')
7474
@dataclass
7575
class ProxyInfo(CrawleeProxyInfo):
7676
"""Provides information about a proxy connection that is used for requests."""
@@ -90,7 +90,7 @@ class ProxyInfo(CrawleeProxyInfo):
9090
"""
9191

9292

93-
@docs_group('Classes')
93+
@docs_group('Configuration')
9494
class ProxyConfiguration(CrawleeProxyConfiguration):
9595
"""Configures a connection to a proxy server with the provided options.
9696

src/apify/_utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ def is_running_in_ipython() -> bool:
3030
return getattr(builtins, '__IPYTHON__', False)
3131

3232

33-
GroupName = Literal['Classes', 'Abstract classes', 'Interfaces', 'Data structures', 'Errors', 'Functions']
33+
# The order of the rendered API groups is defined in the docusaurus-plugin-typedoc-api.
34+
GroupName = Literal[
35+
'Actor',
36+
'Charging',
37+
'Configuration',
38+
'Storage clients',
39+
'Storage data',
40+
'Storages',
41+
'Other',
42+
]
3443

3544

3645
def docs_group(group_name: GroupName) -> Callable: # noqa: ARG001

src/apify/storage_clients/_apify/_models.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
from pydantic import BaseModel, ConfigDict, Field
77

8-
from crawlee._utils.docs import docs_group
98
from crawlee.storage_clients.models import KeyValueStoreMetadata
109

1110
from apify import Request
11+
from apify._utils import docs_group
1212

1313

14-
@docs_group('Data structures')
14+
@docs_group('Storage data')
1515
class ApifyKeyValueStoreMetadata(KeyValueStoreMetadata):
1616
"""Extended key-value store metadata model for Apify platform.
1717
@@ -22,7 +22,7 @@ class ApifyKeyValueStoreMetadata(KeyValueStoreMetadata):
2222
"""The secret key used for signing URLs for secure access to key-value store records."""
2323

2424

25-
@docs_group('Data structures')
25+
@docs_group('Storage data')
2626
class ProlongRequestLockResponse(BaseModel):
2727
"""Response to prolong request lock calls."""
2828

@@ -31,7 +31,7 @@ class ProlongRequestLockResponse(BaseModel):
3131
lock_expires_at: Annotated[datetime, Field(alias='lockExpiresAt')]
3232

3333

34-
@docs_group('Data structures')
34+
@docs_group('Storage data')
3535
class RequestQueueHead(BaseModel):
3636
"""Model for request queue head.
3737
@@ -61,7 +61,10 @@ class RequestQueueHead(BaseModel):
6161

6262

6363
class KeyValueStoreKeyInfo(BaseModel):
64-
"""Model for a key-value store key info."""
64+
"""Model for a key-value store key info.
65+
66+
Only internal structure.
67+
"""
6568

6669
model_config = ConfigDict(populate_by_name=True)
6770

@@ -70,7 +73,10 @@ class KeyValueStoreKeyInfo(BaseModel):
7073

7174

7275
class KeyValueStoreListKeysPage(BaseModel):
73-
"""Model for listing keys in the key-value store."""
76+
"""Model for listing keys in the key-value store.
77+
78+
Only internal structure.
79+
"""
7480

7581
model_config = ConfigDict(populate_by_name=True)
7682

@@ -83,7 +89,10 @@ class KeyValueStoreListKeysPage(BaseModel):
8389

8490

8591
class CachedRequest(BaseModel):
86-
"""Pydantic model for cached request information."""
92+
"""Pydantic model for cached request information.
93+
94+
Only internal structure.
95+
"""
8796

8897
id: str
8998
"""The ID of the request."""

src/apify/storage_clients/_apify/_storage_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
from ._dataset_client import ApifyDatasetClient
1010
from ._key_value_store_client import ApifyKeyValueStoreClient
1111
from ._request_queue_client import ApifyRequestQueueClient
12+
from apify._utils import docs_group
1213

1314
if TYPE_CHECKING:
1415
from crawlee.configuration import Configuration
1516

1617

18+
@docs_group('Storage clients')
1719
class ApifyStorageClient(StorageClient):
1820
"""Apify storage client."""
1921

src/apify/storage_clients/_file_system/_storage_client.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from typing_extensions import override
66

7-
from crawlee._utils.docs import docs_group
87
from crawlee.configuration import Configuration
98
from crawlee.storage_clients import FileSystemStorageClient
109

@@ -14,7 +13,6 @@
1413
from crawlee.storage_clients._file_system import FileSystemKeyValueStoreClient
1514

1615

17-
@docs_group('Classes')
1816
class ApifyFileSystemStorageClient(FileSystemStorageClient):
1917
"""Apify-specific implementation of the file system storage client.
2018

0 commit comments

Comments
 (0)