-
Notifications
You must be signed in to change notification settings - Fork 27.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HF Argparser] Fix parsing of optional boolean arguments #16946
Conversation
@@ -103,7 +103,7 @@ def _parse_dataclass_field(parser: ArgumentParser, field: dataclasses.Field): | |||
kwargs["default"] = field.default | |||
else: | |||
kwargs["required"] = True | |||
elif field.type is bool or field.type is Optional[bool]: | |||
elif field.type is bool or field.type == Optional[bool]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether we should use "==" everywhere for consistency, as we now have both "is" and "==".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me. You should also fix the test on line 143 of this file :-)
The documentation is not available anymore as the PR was closed or merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing!
…#16946) * Add fix * Apply suggestion from code review Co-authored-by: Niels Rogge <nielsrogge@Nielss-MacBook-Pro.local>
…#16946) * Add fix * Apply suggestion from code review Co-authored-by: Niels Rogge <nielsrogge@Nielss-MacBook-Pro.local>
What does this PR do?
This PR fixes a weird bug that made optional boolean arguments not being recognized properly in my virtual environment.
Replacing "is" by "==" fixed the issue.