From 4a378de6c1346a4d7e4e3032ee403ed5adaf10a5 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Fri, 4 Feb 2022 16:29:06 -0600 Subject: [PATCH 1/2] DEPS: unpin numpydoc #39688 --- environment.yml | 2 +- requirements-dev.txt | 2 +- scripts/validate_docstrings.py | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/environment.yml b/environment.yml index 51350a143b913..c2fcb2724e157 100644 --- a/environment.yml +++ b/environment.yml @@ -34,7 +34,7 @@ dependencies: - gitdb - sphinx - sphinx-panels - - numpydoc < 1.2 # 2021-02-09 1.2dev breaking CI + - numpydoc - pydata-sphinx-theme - types-python-dateutil - types-PyMySQL diff --git a/requirements-dev.txt b/requirements-dev.txt index 04ae7f6a97b16..136956d91cc64 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -20,7 +20,7 @@ gitpython gitdb sphinx sphinx-panels -numpydoc < 1.2 +numpydoc pydata-sphinx-theme types-python-dateutil types-PyMySQL diff --git a/scripts/validate_docstrings.py b/scripts/validate_docstrings.py index dcb002fd975c4..1b9dc2de0fdd7 100755 --- a/scripts/validate_docstrings.py +++ b/scripts/validate_docstrings.py @@ -29,8 +29,9 @@ import matplotlib import matplotlib.pyplot as plt import numpy +from numpydoc.docscrape import get_doc_object from numpydoc.validate import ( - Docstring, + Validator, validate, ) @@ -134,7 +135,15 @@ def get_api_items(api_doc_fd): previous_line = line -class PandasDocstring(Docstring): +class PandasDocstring(Validator): + def __init__(self, func_name: str, doc_obj): + self.func_name = func_name + super().__init__(doc_obj) + + @property + def name(self): + return self.func_name + @property def mentioned_private_classes(self): return [klass for klass in PRIVATE_CLASSES if klass in self.raw_doc] @@ -218,8 +227,10 @@ def pandas_validate(func_name: str): dict Information about the docstring and the errors found. """ - doc = PandasDocstring(func_name) - result = validate(func_name) + func_obj = Validator._load_obj(func_name) + doc_obj = get_doc_object(func_obj) + doc = PandasDocstring(func_name, doc_obj) + result = validate(doc_obj) mentioned_errs = doc.mentioned_private_classes if mentioned_errs: From 125a12a1231ae51510a5cfc698de577f6fe60c8b Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Fri, 4 Feb 2022 17:52:34 -0600 Subject: [PATCH 2/2] fix for test --- scripts/validate_docstrings.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/validate_docstrings.py b/scripts/validate_docstrings.py index 1b9dc2de0fdd7..df1971b998bab 100755 --- a/scripts/validate_docstrings.py +++ b/scripts/validate_docstrings.py @@ -136,8 +136,10 @@ def get_api_items(api_doc_fd): class PandasDocstring(Validator): - def __init__(self, func_name: str, doc_obj): + def __init__(self, func_name: str, doc_obj=None): self.func_name = func_name + if doc_obj is None: + doc_obj = get_doc_object(Validator._load_obj(func_name)) super().__init__(doc_obj) @property