MCPcopy Create free account
hub / github.com/apache/arrow / add_docstrings_to_stubs

Function add_docstrings_to_stubs

python/scripts/update_stub_docstrings.py:177–202  ·  view source on GitHub ↗

Update all stub files in stubs_dir with docstrings from pyarrow runtime.

(stubs_dir)

Source from the content-addressed store, hash-verified

175
176
177def add_docstrings_to_stubs(stubs_dir):
178 """Update all stub files in stubs_dir with docstrings from pyarrow runtime."""
179 stubs_dir = Path(stubs_dir)
180 print(f"Updating stub docstrings in: {stubs_dir}")
181
182 pyarrow = importlib.import_module("pyarrow")
183
184 for stub_file in sorted(stubs_dir.rglob('*.pyi')):
185 if stub_file.name == "_stubs_typing.pyi":
186 continue
187
188 module_name = stub_file.stem
189 if module_name in LIB_MODULES:
190 namespace = "lib"
191 elif stub_file.parent.name in ("parquet", "interchange"):
192 namespace = (stub_file.parent.name if module_name == "__init__"
193 else f"{stub_file.parent.name}.{module_name}")
194 elif module_name == "__init__":
195 namespace = ""
196 else:
197 namespace = module_name
198
199 print(f" {stub_file.name} -> {namespace or '(root)'}")
200 tree = libcst.parse_module(stub_file.read_text(encoding="utf-8"))
201 modified = tree.visit(DocstringInserter(pyarrow, namespace))
202 stub_file.write_text(modified.code, encoding="utf-8")
203
204
205def _link_or_copy(source, destination):

Callers 1

Calls 2

DocstringInserterClass · 0.85
PathClass · 0.50

Tested by

no test coverage detected