From b9cf502690ef363b97d98c23985086a92456d140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dea=20Mar=C3=ADa=20L=C3=A9on?= Date: Fri, 21 Jul 2023 15:42:42 +0200 Subject: [PATCH 1/6] =?UTF-8?q?Removed=20InvalidComparison=C2=A0and=C2=A0L?= =?UTF-8?q?ossySetItemError=20from=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci/code_checks.sh | 2 -- doc/source/reference/testing.rst | 2 -- scripts/pandas_errors_documented.py | 6 ++++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 702e7d28a36d8..9ade438960ad3 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -64,8 +64,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then MSG='Partially validate docstrings (EX01)' ; echo $MSG $BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \ pandas.errors.IncompatibilityWarning \ - pandas.errors.InvalidComparison \ - pandas.errors.LossySetitemError \ pandas.errors.NoBufferPresent \ pandas.errors.OptionError \ pandas.errors.PerformanceWarning \ diff --git a/doc/source/reference/testing.rst b/doc/source/reference/testing.rst index a5d61703aceed..0788e51ca7b07 100644 --- a/doc/source/reference/testing.rst +++ b/doc/source/reference/testing.rst @@ -38,11 +38,9 @@ Exceptions and warnings errors.IncompatibilityWarning errors.IndexingError errors.InvalidColumnName - errors.InvalidComparison errors.InvalidIndexError errors.InvalidVersion errors.IntCastingNaNError - errors.LossySetitemError errors.MergeError errors.NoBufferPresent errors.NullFrequencyError diff --git a/scripts/pandas_errors_documented.py b/scripts/pandas_errors_documented.py index b68da137717de..b24cf7dc77f98 100644 --- a/scripts/pandas_errors_documented.py +++ b/scripts/pandas_errors_documented.py @@ -18,16 +18,18 @@ from collections.abc import Sequence API_PATH = pathlib.Path("doc/source/reference/testing.rst").resolve() +PRIVATE_ERRORS = frozenset(["InvalidComparison", "LossySetitemError"]) def get_defined_errors(content: str) -> set[str]: errors = set() for node in ast.walk(ast.parse(content)): - if isinstance(node, ast.ClassDef): + if (isinstance(node, ast.ClassDef)) and (node.name not in PRIVATE_ERRORS): errors.add(node.name) elif isinstance(node, ast.ImportFrom) and node.module != "__future__": for alias in node.names: - errors.add(alias.name) + if alias.name not in PRIVATE_ERRORS: + errors.add(alias.name) return errors From b6f2337a399522bba3f68252b5037808e2d27a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dea=20Mar=C3=ADa=20L=C3=A9on?= Date: Mon, 24 Jul 2023 17:52:21 +0200 Subject: [PATCH 2/6] =?UTF-8?q?Revert=20"Removed=20InvalidComparison=C2=A0?= =?UTF-8?q?and=C2=A0LossySetItemError=20from=20docs"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit b9cf502690ef363b97d98c23985086a92456d140. --- ci/code_checks.sh | 2 ++ doc/source/reference/testing.rst | 2 ++ scripts/pandas_errors_documented.py | 6 ++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 9ade438960ad3..702e7d28a36d8 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -64,6 +64,8 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then MSG='Partially validate docstrings (EX01)' ; echo $MSG $BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \ pandas.errors.IncompatibilityWarning \ + pandas.errors.InvalidComparison \ + pandas.errors.LossySetitemError \ pandas.errors.NoBufferPresent \ pandas.errors.OptionError \ pandas.errors.PerformanceWarning \ diff --git a/doc/source/reference/testing.rst b/doc/source/reference/testing.rst index 0788e51ca7b07..a5d61703aceed 100644 --- a/doc/source/reference/testing.rst +++ b/doc/source/reference/testing.rst @@ -38,9 +38,11 @@ Exceptions and warnings errors.IncompatibilityWarning errors.IndexingError errors.InvalidColumnName + errors.InvalidComparison errors.InvalidIndexError errors.InvalidVersion errors.IntCastingNaNError + errors.LossySetitemError errors.MergeError errors.NoBufferPresent errors.NullFrequencyError diff --git a/scripts/pandas_errors_documented.py b/scripts/pandas_errors_documented.py index b24cf7dc77f98..b68da137717de 100644 --- a/scripts/pandas_errors_documented.py +++ b/scripts/pandas_errors_documented.py @@ -18,18 +18,16 @@ from collections.abc import Sequence API_PATH = pathlib.Path("doc/source/reference/testing.rst").resolve() -PRIVATE_ERRORS = frozenset(["InvalidComparison", "LossySetitemError"]) def get_defined_errors(content: str) -> set[str]: errors = set() for node in ast.walk(ast.parse(content)): - if (isinstance(node, ast.ClassDef)) and (node.name not in PRIVATE_ERRORS): + if isinstance(node, ast.ClassDef): errors.add(node.name) elif isinstance(node, ast.ImportFrom) and node.module != "__future__": for alias in node.names: - if alias.name not in PRIVATE_ERRORS: - errors.add(alias.name) + errors.add(alias.name) return errors From 60295b877d144aa652c9073427826471083a1731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dea=20Mar=C3=ADa=20L=C3=A9on?= Date: Mon, 24 Jul 2023 18:20:33 +0200 Subject: [PATCH 3/6] internal errors --- pandas/errors/__init__.py | 8 ++++++++ scripts/validate_docstrings.py | 3 +++ 2 files changed, 11 insertions(+) diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index ba2723fe66744..9a97967b10c68 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -686,6 +686,10 @@ class CategoricalConversionWarning(Warning): class LossySetitemError(Exception): """ Raised when trying to do a __setitem__ on an np.ndarray that is not lossless. + + Examples + -------- + This is an internal error. Please do not use it. """ @@ -698,6 +702,10 @@ class NoBufferPresent(Exception): class InvalidComparison(Exception): """ Exception is raised by _validate_comparison_value to indicate an invalid comparison. + + Examples + -------- + This is an internal error. Please do not use it. """ diff --git a/scripts/validate_docstrings.py b/scripts/validate_docstrings.py index 61a03937f8ec6..c55301bc45a3f 100755 --- a/scripts/validate_docstrings.py +++ b/scripts/validate_docstrings.py @@ -49,6 +49,9 @@ "Styler.template_latex", "Styler.template_string", "Styler.loader", + "errors.InvalidComparison", + "errors.LossySetitemError", + "", } PRIVATE_CLASSES = ["NDFrame", "IndexOpsMixin"] ERROR_MSGS = { From 69bcc970c18df529411b3444bb71190c7b03c707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dea=20Mar=C3=ADa=20L=C3=A9on?= Date: Mon, 24 Jul 2023 19:05:36 +0200 Subject: [PATCH 4/6] Examples to Notes on docstring --- pandas/errors/__init__.py | 8 ++++---- scripts/validate_docstrings.py | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index 9a97967b10c68..606b5e6dbc564 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -687,9 +687,9 @@ class LossySetitemError(Exception): """ Raised when trying to do a __setitem__ on an np.ndarray that is not lossless. - Examples + Notes -------- - This is an internal error. Please do not use it. + This is an internal error. """ @@ -703,9 +703,9 @@ class InvalidComparison(Exception): """ Exception is raised by _validate_comparison_value to indicate an invalid comparison. - Examples + Notes -------- - This is an internal error. Please do not use it. + This is an internal error. """ diff --git a/scripts/validate_docstrings.py b/scripts/validate_docstrings.py index c55301bc45a3f..94ddd300d4ea5 100755 --- a/scripts/validate_docstrings.py +++ b/scripts/validate_docstrings.py @@ -51,7 +51,6 @@ "Styler.loader", "errors.InvalidComparison", "errors.LossySetitemError", - "", } PRIVATE_CLASSES = ["NDFrame", "IndexOpsMixin"] ERROR_MSGS = { From 09cc1fb9d9aab181f92b2cc4526612d96527bffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dea=20Mar=C3=ADa=20L=C3=A9on?= Date: Mon, 24 Jul 2023 19:07:04 +0200 Subject: [PATCH 5/6] removed extra lines --- pandas/errors/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index 606b5e6dbc564..71e12109292ae 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -688,7 +688,7 @@ class LossySetitemError(Exception): Raised when trying to do a __setitem__ on an np.ndarray that is not lossless. Notes - -------- + ----- This is an internal error. """ @@ -704,7 +704,7 @@ class InvalidComparison(Exception): Exception is raised by _validate_comparison_value to indicate an invalid comparison. Notes - -------- + ----- This is an internal error. """ From f12523f08ebe17a94bc190d0574960b362c7013c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dea=20Mar=C3=ADa=20L=C3=A9on?= Date: Mon, 24 Jul 2023 19:42:26 +0200 Subject: [PATCH 6/6] merge w main and code_check change --- ci/code_checks.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 086629d46429c..019693ffa089e 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -64,8 +64,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then MSG='Partially validate docstrings (EX01)' ; echo $MSG $BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \ pandas.errors.IncompatibilityWarning \ - pandas.errors.InvalidComparison \ - pandas.errors.LossySetitemError \ pandas.errors.NoBufferPresent \ pandas.errors.OptionError \ pandas.errors.PerformanceWarning \