Unverified Commit 63f2b9ab authored by Sylvain Gugger's avatar Sylvain Gugger Committed by GitHub
Browse files

Print defaults when using --help for scripts (#12930)

parent 3ec851dc
......@@ -16,7 +16,7 @@ import dataclasses
import json
import re
import sys
from argparse import ArgumentParser, ArgumentTypeError
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError
from enum import Enum
from pathlib import Path
from typing import Any, Iterable, List, NewType, Optional, Tuple, Union
......@@ -59,6 +59,9 @@ class HfArgumentParser(ArgumentParser):
kwargs:
(Optional) Passed to `argparse.ArgumentParser()` in the regular way.
"""
# To make the default appear when using --help
if "formatter_class" not in kwargs:
kwargs["formatter_class"] = ArgumentDefaultsHelpFormatter
super().__init__(**kwargs)
if dataclasses.is_dataclass(dataclass_types):
dataclass_types = [dataclass_types]
......
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