-
Notifications
You must be signed in to change notification settings - Fork 27.7k
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
Support union types X | Y
syntax for HfArgumentParser
for Python 3.10+
#23126
Conversation
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 a lot for adding support and new tests! Left a couple of nits in the test file and we should be able to merge this.
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 iterating!
…3.10+ (huggingface#23126) * Support union types `X | Y` syntax for `HfArgumentParser` for Python 3.10+ * Add tests for PEP 604 for `HfArgumentParser` * Reorganize tests
…3.10+ (huggingface#23126) * Support union types `X | Y` syntax for `HfArgumentParser` for Python 3.10+ * Add tests for PEP 604 for `HfArgumentParser` * Reorganize tests
What does this PR do?
Support union types
X | Y
syntax forHfArgumentParser
for Python 3.10+. Allow users using Python 3.10+ to opt in new typing futures, such as union typesX | Y
(PEP 604). Note thattyping.get_type_hints
does not work for union types on Python 3.7-3.9.Fixes #20249
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Testing union types
X | Y
for Python 3.7-3.9 needs to addfrom __future__ import annotations
at the top of the test script. I'm not sure should we need to create a separate test script or add new test cases directly intests/utils/test_hf_argparser.py
.Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.