|
31 | 31 | from pathlib import Path |
32 | 32 | from textwrap import indent |
33 | 33 |
|
34 | | -# Add current directory to path to find locally built pyarrow |
35 | | -sys.path.insert(0, ".") |
36 | | - |
37 | 34 | import libcst |
38 | 35 | from libcst import matchers as m |
39 | 36 |
|
| 37 | +# Add current directory to path to find locally built pyarrow |
| 38 | +sys.path.insert(0, ".") |
| 39 | + |
40 | 40 |
|
41 | 41 | def _resolve_object(module, path): |
42 | 42 | """ |
@@ -66,13 +66,8 @@ def _resolve_object(module, path): |
66 | 66 | try: |
67 | 67 | obj = getattr(obj, part) |
68 | 68 | except AttributeError: |
69 | | - # Fallback: try __dict__ access for special methods like __init__ |
| 69 | + # Fallback: try vars() for special methods like __init__ |
70 | 70 | # that may not be directly accessible via getattr |
71 | | - if hasattr(parent, "__dict__"): |
72 | | - obj = parent.__dict__.get(part) |
73 | | - if obj is not None: |
74 | | - continue |
75 | | - # Try vars() as another fallback |
76 | 71 | try: |
77 | 72 | obj = vars(parent).get(part) |
78 | 73 | if obj is not None: |
@@ -137,7 +132,7 @@ def _get_docstring(name, module, indentation): |
137 | 132 | return docstring |
138 | 133 |
|
139 | 134 |
|
140 | | -class ReplaceEllipsis(libcst.CSTTransformer): |
| 135 | +class DocstringInserter(libcst.CSTTransformer): |
141 | 136 | def __init__(self, module, namespace): |
142 | 137 | self.module = module |
143 | 138 | self.base_namespace = namespace |
@@ -277,7 +272,7 @@ def add_docs_to_stub_files(pyarrow_folder): |
277 | 272 | elif module == "__init__": |
278 | 273 | module = "" |
279 | 274 |
|
280 | | - modified_tree = tree.visit(ReplaceEllipsis(pyarrow_module, module)) |
| 275 | + modified_tree = tree.visit(DocstringInserter(pyarrow_module, module)) |
281 | 276 | with open(stub_file, "w") as f: |
282 | 277 | f.write(modified_tree.code) |
283 | 278 | print("\n") |
|
0 commit comments