KEMBAR78
[HF Argparser] Fix parsing of optional boolean arguments by NielsRogge · Pull Request #16946 · huggingface/transformers · GitHub
Skip to content

Conversation

@NielsRogge
Copy link
Contributor

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.

@NielsRogge NielsRogge requested a review from sgugger April 26, 2022 14:11
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]:
Copy link
Contributor Author

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 "==".

Copy link
Collaborator

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 :-)

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 26, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing!

@NielsRogge NielsRogge merged commit 084c38c into huggingface:main Apr 27, 2022
chamidullinr pushed a commit to chamidullinr/transformers that referenced this pull request Apr 28, 2022
…#16946)

* Add fix

* Apply suggestion from code review

Co-authored-by: Niels Rogge <nielsrogge@Nielss-MacBook-Pro.local>
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
…#16946)

* Add fix

* Apply suggestion from code review

Co-authored-by: Niels Rogge <nielsrogge@Nielss-MacBook-Pro.local>
JunnYu added a commit to JunnYu/PaddleNLP that referenced this pull request Aug 2, 2023
sijunhe pushed a commit to PaddlePaddle/PaddleNLP that referenced this pull request Aug 2, 2023
triple-Mu pushed a commit to triple-Mu/PaddleNLP that referenced this pull request Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants