Fix hf_argparser.parse_json_file to open file with utf-8 encoding, close file when finished (#23194)
* Open json args in utf-8 encoding, close file when finished * black formatted
This commit is contained in:
parent
6f8a02844a
commit
dbc12269ed
|
@ -401,8 +401,8 @@ class HfArgumentParser(ArgumentParser):
|
|||
|
||||
- the dataclass instances in the same order as they were passed to the initializer.
|
||||
"""
|
||||
open_json_file = open(Path(json_file))
|
||||
data = json.loads(open_json_file.read())
|
||||
with open(Path(json_file), encoding="utf-8") as open_json_file:
|
||||
data = json.loads(open_json_file.read())
|
||||
outputs = self.parse_dict(data, allow_extra_keys=allow_extra_keys)
|
||||
return tuple(outputs)
|
||||
|
||||
|
|
Loading…
Reference in New Issue