Skip to content

Commit

Permalink
Fix docstring checker issues with PIL enums (huggingface#28450)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rocketknight1 authored Jan 11, 2024
1 parent 19e83d1 commit 1434513
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions utils/check_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1434513

Please sign in to comment.