From 0a7507d1b32b53e68340296421499a2763527f26 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Thu, 10 Feb 2022 20:02:53 -0600 Subject: [PATCH] DEPS/DOC: unpin numpydoc #39688 (#45830) --- environment.yml | 2 +- requirements-dev.txt | 2 +- scripts/validate_docstrings.py | 21 +++++++++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/environment.yml b/environment.yml index c6395cf7e3728..2c6a6c95569d6 100644 --- a/environment.yml +++ b/environment.yml @@ -32,7 +32,7 @@ dependencies: # documentation - gitpython # obtain contributors from git for whatsnew - gitdb - - numpydoc < 1.2 # 2021-02-09 1.2dev breaking CI + - numpydoc - pandas-dev-flaker=0.4.0 - pydata-sphinx-theme - pytest-cython diff --git a/requirements-dev.txt b/requirements-dev.txt index b3832dd7f2b6a..94a1d344b4849 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -18,7 +18,7 @@ pycodestyle pyupgrade gitpython gitdb -numpydoc < 1.2 +numpydoc pandas-dev-flaker==0.4.0 pydata-sphinx-theme pytest-cython diff --git a/scripts/validate_docstrings.py b/scripts/validate_docstrings.py index dcb002fd975c4..df1971b998bab 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,17 @@ def get_api_items(api_doc_fd): previous_line = line -class PandasDocstring(Docstring): +class PandasDocstring(Validator): + 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 + 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 +229,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: