Skip to content

Commit c819378

Browse files
committed
Remove json_util.load()
1 parent 29332c3 commit c819378

File tree

2 files changed

+1
-25
lines changed

2 files changed

+1
-25
lines changed

bson/json_util.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -507,29 +507,6 @@ def loads(s: Union[str, bytes, bytearray], *args: Any, **kwargs: Any) -> Any:
507507
return json.loads(s, *args, **kwargs)
508508

509509

510-
def load(fp: Any, *args: Any, **kwargs: Any) -> Any:
511-
"""Helper function that wraps :func:`json.load`.
512-
513-
Automatically passes the object_hook for BSON type conversion.
514-
515-
Raises ``TypeError``, ``ValueError``, ``KeyError``, or
516-
:exc:`~bson.errors.InvalidId` on invalid MongoDB Extended JSON.
517-
518-
:param json_options: A :class:`JSONOptions` instance used to modify the
519-
decoding of MongoDB Extended JSON types. Defaults to
520-
:const:`DEFAULT_JSON_OPTIONS`.
521-
522-
.. versionadded:: 4.12
523-
"""
524-
json_options = kwargs.pop("json_options", DEFAULT_JSON_OPTIONS)
525-
# Execution time optimization if json_options.document_class is dict
526-
if json_options.document_class is dict:
527-
kwargs["object_hook"] = lambda obj: object_hook(obj, json_options)
528-
else:
529-
kwargs["object_pairs_hook"] = lambda pairs: object_pairs_hook(pairs, json_options)
530-
return json.load(fp, *args, **kwargs)
531-
532-
533510
def _json_convert(obj: Any, json_options: JSONOptions = DEFAULT_JSON_OPTIONS) -> Any:
534511
"""Recursive helper method that converts BSON types so they can be
535512
converted into json.

test/test_bson_binary_vector.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import binascii
1818
import codecs
19-
import json
2019
import struct
2120
from pathlib import Path
2221
from test import unittest
@@ -101,7 +100,7 @@ def run_test(self):
101100
def create_tests():
102101
for filename in _TEST_PATH.glob("*.json"):
103102
with codecs.open(str(filename), encoding="utf-8") as test_file:
104-
test_method = create_test(json_util.load(test_file))
103+
test_method = create_test(json_util.loads(test_file.read()))
105104
setattr(TestBSONBinaryVector, "test_" + filename.stem, test_method)
106105

107106

0 commit comments

Comments
 (0)