diff --git a/CHANGES.rst b/CHANGES.rst index 945237cd..0d96a61e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,9 @@ Version 2.1.2 Unreleased +- Fix type annotation for ``json.loads``, it accepts str or bytes. + :issue:`4519` + Version 2.1.1 ------------- diff --git a/src/flask/json/__init__.py b/src/flask/json/__init__.py index 43c018e7..edc9793d 100644 --- a/src/flask/json/__init__.py +++ b/src/flask/json/__init__.py @@ -153,7 +153,11 @@ def dump( _json.dump(obj, fp, **kwargs) -def loads(s: str, app: t.Optional["Flask"] = None, **kwargs: t.Any) -> t.Any: +def loads( + s: t.Union[str, bytes], + app: t.Optional["Flask"] = None, + **kwargs: t.Any, +) -> t.Any: """Deserialize an object from a string of JSON. Takes the same arguments as the built-in :func:`json.loads`, with