From 143451355cde90ac2819452d65d219a7c86cad72 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 11 Jan 2024 17:23:41 +0000 Subject: [PATCH] Fix docstring checker issues with PIL enums (#28450) --- utils/check_docstrings.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/check_docstrings.py b/utils/check_docstrings.py index cd6d0dc33f47..ca8141ebb420 100644 --- a/utils/check_docstrings.py +++ b/utils/check_docstrings.py @@ -933,6 +933,10 @@ def replace_default_in_arg_description(description: str, default: Any) -> str: except Exception: # Otherwise there is a math operator so we add a code block. str_default = f"`{current_default}`" + elif isinstance(default, enum.Enum) and default.name == current_default.split(".")[-1]: + # When the default is an Enum (this is often the case for PIL.Image.Resampling), and the docstring + # matches the enum name, keep the existing docstring rather than clobbering it with the enum value. + str_default = f"`{current_default}`" if str_default is None: str_default = stringify_default(default)