Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-3562

Type annotation of `bson.json_utils.loads` is incorrect (only accepts `str`)

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.4
    • Affects Version/s: None
    • Component/s: Typing
    • None

      The type annotations in the definition of the `bson.json_util.loads` function is incorrect. It says the function only accepts `str`. But, since it delegate it's implementation to the Python standard library `json` module, it in facts allows decoding `str`, `bytes` and `bytearray` (cf. documentation).

      Note that forcing user to pass a str could have a negative impact on performances. I didn't do any benchmarks yet.

            Assignee:
            julius.park@mongodb.com Julius Park (Inactive)
            Reporter:
            nicolas.caniart@wematch.live Nicolas Caniart
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: