mirror of
https://github.com/huggingface/transformers.git
synced 2025-08-02 03:01:07 +06:00
Fix docstring checker issues with PIL enums (#28450)
This commit is contained in:
parent
19e83d174c
commit
143451355c
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user