MCPcopy
hub / github.com/pandas-dev/pandas / pandas_validate

Function pandas_validate

scripts/validate_docstrings.py:233–300  ·  view source on GitHub ↗

Call the numpydoc validation, and add the errors specific to pandas. Parameters ---------- func_name : str Name of the object of the docstring to validate. Returns ------- dict Information about the docstring and the errors found.

(func_name: str)

Source from the content-addressed store, hash-verified

231
232
233def pandas_validate(func_name: str):
234 """
235 Call the numpydoc validation, and add the errors specific to pandas.
236
237 Parameters
238 ----------
239 func_name : str
240 Name of the object of the docstring to validate.
241
242 Returns
243 -------
244 dict
245 Information about the docstring and the errors found.
246 """
247 func_obj = Validator._load_obj(func_name)
248 # Some objects are instances, e.g. IndexSlice, which numpydoc can't validate
249 doc_obj = get_doc_object(func_obj, doc=func_obj.__doc__)
250 doc = PandasDocstring(func_name, doc_obj)
251 if func_obj.__doc__ is not None:
252 result = validate(doc_obj)
253 else:
254 result = {
255 "docstring": "",
256 "file": None,
257 "file_line": None,
258 "errors": [("GL08", "The object does not have a docstring")],
259 }
260 mentioned_errs = doc.mentioned_private_classes
261 if mentioned_errs:
262 result["errors"].append(
263 pandas_error("GL04", mentioned_private_classes=", ".join(mentioned_errs))
264 )
265
266 if doc.see_also:
267 result["errors"].extend(
268 pandas_error(
269 "SA05",
270 reference_name=rel_name,
271 right_reference=rel_name[len("pandas.") :],
272 )
273 for rel_name in doc.see_also
274 if rel_name.startswith("pandas.")
275 )
276
277 result["examples_errs"] = ""
278 if doc.examples:
279 for error_code, error_message, line_number, col_number in doc.validate_pep8():
280 result["errors"].append(
281 pandas_error(
282 "EX03",
283 error_code=error_code,
284 error_message=error_message,
285 line_number=line_number,
286 col_number=col_number,
287 )
288 )
289 examples_source_code = "".join(doc.examples_source_code)
290 result["errors"].extend(

Callers 2

validate_allFunction · 0.85

Calls 8

validate_pep8Method · 0.95
PandasDocstringClass · 0.85
pandas_errorFunction · 0.85
startswithMethod · 0.80
appendMethod · 0.45
joinMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected