|
6 | 6 | from redbaron import RedBaron |
7 | 7 | from utils import sync_to_async_docstring |
8 | 8 |
|
| 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 | + |
9 | 15 | # Get the directory of the source files |
10 | 16 | clients_path = Path(__file__).parent.resolve() / '../src/apify_client' |
11 | 17 |
|
|
30 | 36 | # Find corresponding sync method in the sync class |
31 | 37 | sync_method = sync_class.find('DefNode', name=async_method.name) |
32 | 38 |
|
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: |
35 | 45 | continue |
36 | 46 |
|
37 | 47 | # Skip methods that don't exist in the sync class |
38 | 48 | if sync_method is None: |
39 | 49 | continue |
40 | 50 |
|
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 | | - |
52 | 51 | # If the sync method has a docstring, copy it to the async method (with adjustments) |
53 | 52 | if isinstance(sync_method.value[0].value, str): |
54 | 53 | sync_docstring = sync_method.value[0].value |
|
0 commit comments