Unverified Commit 14345135 authored by Matt's avatar Matt Committed by GitHub
Browse files

Fix docstring checker issues with PIL enums (#28450)

parent 19e83d17
...@@ -933,6 +933,10 @@ def replace_default_in_arg_description(description: str, default: Any) -> str: ...@@ -933,6 +933,10 @@ def replace_default_in_arg_description(description: str, default: Any) -> str:
except Exception: except Exception:
# Otherwise there is a math operator so we add a code block. # Otherwise there is a math operator so we add a code block.
str_default = f"`{current_default}`" 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: if str_default is None:
str_default = stringify_default(default) str_default = stringify_default(default)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment