[Bugfix] Fix FlexibleArgumentParser replaces _ with - for actual args (#5795)

This commit is contained in:
Chang Su 2024-06-24 16:01:19 -07:00 committed by GitHub
parent 1744cc99ba
commit ba991d5c84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -822,7 +822,13 @@ class FlexibleArgumentParser(argparse.ArgumentParser):
processed_args = []
for arg in args:
if arg.startswith('--'):
processed_args.append('--' + arg[len('--'):].replace('_', '-'))
if '=' in arg:
key, value = arg.split('=', 1)
key = '--' + key[len('--'):].replace('_', '-')
processed_args.append(f'{key}={value}')
else:
processed_args.append('--' +
arg[len('--'):].replace('_', '-'))
else:
processed_args.append(arg)