Skip to content

Commit fe5c92f

Browse files
committed
Use alternative constructor
1 parent 54d2a77 commit fe5c92f

5 files changed

Lines changed: 193 additions & 309 deletions

File tree

‎scripts/check_async_docstrings.py‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111

1212
found_issues = False
1313

14+
# Methods where the async docstring is intentionally different from the sync one
15+
# (e.g. because they accept different parameter types).
16+
SKIPPED_METHODS = {
17+
'with_custom_client',
18+
}
19+
1420
# Get the directory of the source files
1521
clients_path = Path(__file__).parent.resolve() / '../src/apify_client'
1622

@@ -33,18 +39,13 @@
3339
# Find corresponding sync method in the sync class
3440
sync_method = sync_class.find('DefNode', name=async_method.name)
3541

36-
# Skip methods with @ignore_docs or @overload decorator
37-
if len(async_method.decorators) and str(async_method.decorators[0].value) in ('ignore_docs', 'overload'):
42+
# Skip methods with @ignore_docs decorator
43+
if len(async_method.decorators) and str(async_method.decorators[0].value) == 'ignore_docs':
3844
continue
3945

40-
# When there are overloads, find() may return a stub instead of the implementation.
41-
# Find the actual implementation by skipping overload-decorated methods.
42-
if sync_method and any(str(d.value) == 'overload' for d in sync_method.decorators):
43-
candidates = sync_class.find_all('DefNode', name=async_method.name)
44-
sync_method = next(
45-
(m for m in candidates if not any(str(d.value) == 'overload' for d in m.decorators)),
46-
None,
47-
)
46+
# Skip methods whose docstrings are intentionally different
47+
if async_method.name in SKIPPED_METHODS:
48+
continue
4849

4950
# If the sync method has a docstring, check if it matches the async dostring
5051
if sync_method and isinstance(sync_method.value[0].value, str):

‎scripts/fix_async_docstrings.py‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
from redbaron import RedBaron
77
from utils import sync_to_async_docstring
88

9+
# Methods where the async docstring is intentionally different from the sync one
10+
# (e.g. because they accept different parameter types).
11+
SKIPPED_METHODS = {
12+
'with_custom_client',
13+
}
14+
915
# Get the directory of the source files
1016
clients_path = Path(__file__).parent.resolve() / '../src/apify_client'
1117

@@ -30,25 +36,18 @@
3036
# Find corresponding sync method in the sync class
3137
sync_method = sync_class.find('DefNode', name=async_method.name)
3238

33-
# Skip methods with @ignore_docs or @overload decorator
34-
if len(async_method.decorators) and str(async_method.decorators[0].value) in ('ignore_docs', 'overload'):
39+
# Skip methods with @ignore_docs decorator
40+
if len(async_method.decorators) and str(async_method.decorators[0].value) == 'ignore_docs':
41+
continue
42+
43+
# Skip methods whose docstrings are intentionally different
44+
if async_method.name in SKIPPED_METHODS:
3545
continue
3646

3747
# Skip methods that don't exist in the sync class
3848
if sync_method is None:
3949
continue
4050

41-
# When there are overloads, find() may return a stub instead of the implementation.
42-
# Find the actual implementation by skipping overload-decorated methods.
43-
if any(str(d.value) == 'overload' for d in sync_method.decorators):
44-
candidates = sync_class.find_all('DefNode', name=async_method.name)
45-
sync_method = next(
46-
(m for m in candidates if not any(str(d.value) == 'overload' for d in m.decorators)),
47-
None,
48-
)
49-
if sync_method is None:
50-
continue
51-
5251
# If the sync method has a docstring, copy it to the async method (with adjustments)
5352
if isinstance(sync_method.value[0].value, str):
5453
sync_docstring = sync_method.value[0].value

0 commit comments

Comments
 (0)