Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
fa1a8d10
Commit
fa1a8d10
authored
Mar 11, 2021
by
Sylvain Gugger
Browse files
Tentative fix for HFArgumentParser in Python 3.8
parent
2f848519
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
src/transformers/hf_argparser.py
src/transformers/hf_argparser.py
+4
-1
No files found.
src/transformers/hf_argparser.py
View file @
fa1a8d10
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
import
dataclasses
import
dataclasses
import
json
import
json
import
re
import
sys
import
sys
from
argparse
import
ArgumentParser
,
ArgumentTypeError
from
argparse
import
ArgumentParser
,
ArgumentTypeError
from
enum
import
Enum
from
enum
import
Enum
...
@@ -113,7 +114,9 @@ class HfArgumentParser(ArgumentParser):
...
@@ -113,7 +114,9 @@ class HfArgumentParser(ArgumentParser):
kwargs
[
"nargs"
]
=
"?"
kwargs
[
"nargs"
]
=
"?"
# This is the value that will get picked if we do --field_name (without value)
# This is the value that will get picked if we do --field_name (without value)
kwargs
[
"const"
]
=
True
kwargs
[
"const"
]
=
True
elif
hasattr
(
field
.
type
,
"__origin__"
)
and
issubclass
(
field
.
type
.
__origin__
,
List
):
elif
(
hasattr
(
field
.
type
,
"__origin__"
)
and
re
.
search
(
r
"^typing\.List\[(.*)\]$"
,
str
(
field
.
type
))
is
not
None
):
kwargs
[
"nargs"
]
=
"+"
kwargs
[
"nargs"
]
=
"+"
kwargs
[
"type"
]
=
field
.
type
.
__args__
[
0
]
kwargs
[
"type"
]
=
field
.
type
.
__args__
[
0
]
assert
all
(
assert
all
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment