Skip to content

Commit a0e06bf

Browse files
committed
ci: replace redbaron with griffe in async docstring scripts
1 parent b2d637e commit a0e06bf

File tree

6 files changed

+36
-91
lines changed

6 files changed

+36
-91
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ dev = [
4848
"black>=24.3.0",
4949
"datamodel-code-generator[http,ruff]<1.0.0",
5050
"dycw-pytest-only<3.0.0",
51-
"griffe",
51+
"griffe<3.0.0",
5252
"poethepoet<1.0.0",
5353
"pre-commit<5.0.0",
5454
"pydoc-markdown<5.0.0",

scripts/_utils.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import pathlib
2+
import re
3+
4+
PACKAGE_NAME = 'apify_client'
5+
REPO_ROOT = pathlib.Path(__file__).parent.resolve() / '..'
6+
PYPROJECT_TOML_FILE_PATH = REPO_ROOT / 'pyproject.toml'
7+
8+
9+
SKIPPED_METHODS = {
10+
'with_custom_http_client',
11+
}
12+
"""Components where the async and sync docstrings are intentionally different."""
13+
14+
15+
def sync_to_async_docstring(docstring: str) -> str:
16+
"""Convert a docstring from a sync component version into a docstring for its async analogue."""
17+
substitutions = [
18+
(r'Client', r'ClientAsync'),
19+
(r'\bsynchronously\b', r'asynchronously'),
20+
(r'\bSynchronously\b', r'Asynchronously'),
21+
(r'\bsynchronous\b', r'asynchronous'),
22+
(r'\bSynchronous\b', r'Asynchronous'),
23+
(r'Retry a function', r'Retry an async function'),
24+
(r'Function to retry', r'Async function to retry'),
25+
]
26+
res = docstring
27+
for pattern, replacement in substitutions:
28+
res = re.sub(pattern, replacement, res, flags=re.MULTILINE)
29+
return res

scripts/check_async_docstrings.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env python
22

33
"""Check if async docstrings are the same as sync."""
44

@@ -7,15 +7,10 @@
77
from pathlib import Path
88

99
from griffe import Module, load
10-
from utils import sync_to_async_docstring
1110

12-
found_issues = False
11+
from ._utils import SKIPPED_METHODS, sync_to_async_docstring
1312

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_http_client',
18-
}
13+
found_issues = False
1914

2015
# Load the apify_client package
2116
src_path = Path(__file__).parent.resolve() / '../src'

scripts/fix_async_docstrings.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env python
22

33
import ast
44
from collections.abc import Generator
55
from pathlib import Path
66

77
from griffe import Module, load
8-
from utils import sync_to_async_docstring
98

10-
# Methods where the async docstring is intentionally different from the sync one
11-
# (e.g. because they accept different parameter types).
12-
SKIPPED_METHODS = {
13-
'with_custom_http_client',
14-
}
9+
from ._utils import SKIPPED_METHODS, sync_to_async_docstring
1510

1611
# Load the apify_client package
1712
src_path = Path(__file__).parent.resolve() / '../src'

scripts/utils.py

Lines changed: 0 additions & 74 deletions
This file was deleted.

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)