Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-canonicaljson for openSUSE:Factory checked in at 2022-06-08 14:24:55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-canonicaljson (Old) and /work/SRC/openSUSE:Factory/.python-canonicaljson.new.1548 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-canonicaljson" Wed Jun 8 14:24:55 2022 rev:11 rq:981280 version:1.6.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-canonicaljson/python-canonicaljson.changes 2022-05-12 23:00:04.916774374 +0200 +++ /work/SRC/openSUSE:Factory/.python-canonicaljson.new.1548/python-canonicaljson.changes 2022-06-08 14:25:18.584531274 +0200 @@ -1,0 +2,14 @@ +Wed Jun 8 10:00:55 UTC 2022 - Marcus Rueckert <mrueck...@suse.de> + +- Update to 1.6.2 + - Add type annotations (#49). + - 1.6.2 is a rerelease of 1.6.1 with the version numbers fixed in + the tarball. + +------------------------------------------------------------------- +Tue Jun 7 17:33:11 UTC 2022 - Marcus Rueckert <mrueck...@suse.de> + +- Update to 1.6.0 + - Make frozendict import conditional. by @BURG3R5 in #46 + +------------------------------------------------------------------- Old: ---- v1.5.0.tar.gz New: ---- v1.6.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-canonicaljson.spec ++++++ --- /var/tmp/diff_new_pack.UdwJAA/_old 2022-06-08 14:25:19.064531870 +0200 +++ /var/tmp/diff_new_pack.UdwJAA/_new 2022-06-08 14:25:19.068531874 +0200 @@ -25,16 +25,22 @@ %bcond_with test %endif %{?!python_module:%define python_module() python-%{**} python3-%{**}} +%bcond_with pyproject %define github_user matrix-org %define short_name canonicaljson Name: python-%{short_name}%{psuffix} -Version: 1.5.0 +Version: 1.6.2 Release: 0 Summary: Canonical JSON for Python License: Apache-2.0 Group: Development/Languages/Python URL: https://github.com/matrix-org/python-canonicaljson Source: https://github.com/matrix-org/python-canonicaljson/archive/v%{version}.tar.gz +%if %{with pyproject} +BuildRequires: %{python_module flit-core} +BuildRequires: %{python_module pip} +BuildRequires: %{python_module wheel} +%endif BuildRequires: %{python_module frozendict >= 2.1.3} BuildRequires: %{python_module setuptools} BuildRequires: %{python_module simplejson >= 3.14.0} @@ -65,11 +71,19 @@ %setup -q -n python-canonicaljson-%{version} %build +%if %{with pyproject} +%pyproject_wheel +%else %python_build +%endif %install %if !%{with test} +%if %{with pyproject} +%pyproject_install +%else %python_install +%endif %python_expand %fdupes %{buildroot}%{$python_sitelib} %endif ++++++ v1.5.0.tar.gz -> v1.6.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-canonicaljson-1.5.0/.github/CODEOWNERS new/python-canonicaljson-1.6.2/.github/CODEOWNERS --- old/python-canonicaljson-1.5.0/.github/CODEOWNERS 1970-01-01 01:00:00.000000000 +0100 +++ new/python-canonicaljson-1.6.2/.github/CODEOWNERS 2022-06-08 11:33:29.000000000 +0200 @@ -0,0 +1,2 @@ +# Automatically request reviews from the synapse-core team when a pull request comes in. +* @matrix-org/synapse-core diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-canonicaljson-1.5.0/.github/workflows/tests.yaml new/python-canonicaljson-1.6.2/.github/workflows/tests.yaml --- old/python-canonicaljson-1.5.0/.github/workflows/tests.yaml 2021-10-08 18:24:57.000000000 +0200 +++ new/python-canonicaljson-1.6.2/.github/workflows/tests.yaml 2022-06-08 11:33:29.000000000 +0200 @@ -1,6 +1,10 @@ name: Tests on: [push, pull_request] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: lint: runs-on: ubuntu-latest @@ -9,12 +13,13 @@ toxenv: - "pep8" - "black" + - "mypy" steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: - python-version: '3.6' + python-version: '3.7' - run: pip install tox - run: tox -e ${{ matrix.toxenv }} @@ -22,7 +27,7 @@ runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.5', '3.6', '3.7', '3.8', '3.9', '3.10', 'pypy3'] + python-version: ['3.7', '3.8', '3.9', '3.10', 'pypy-3.7'] steps: - uses: actions/checkout@v2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-canonicaljson-1.5.0/CHANGES.md new/python-canonicaljson-1.6.2/CHANGES.md --- old/python-canonicaljson-1.5.0/CHANGES.md 2021-10-08 18:24:57.000000000 +0200 +++ new/python-canonicaljson-1.6.2/CHANGES.md 2022-06-08 11:33:29.000000000 +0200 @@ -1,4 +1,8 @@ -Version 1.5.0 released 2021-10-08 +Version 1.6.0 released 2022-03-04 + +* `frozendict` is now an optional dependency; it is no longer required. + +Version 1.5.0 released 2021-10-20 * Switch CI from Travis to Github Actions * Add code to handle frozendict implementations using c-extension diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-canonicaljson-1.5.0/MANIFEST.in new/python-canonicaljson-1.6.2/MANIFEST.in --- old/python-canonicaljson-1.5.0/MANIFEST.in 2021-10-08 18:24:57.000000000 +0200 +++ new/python-canonicaljson-1.6.2/MANIFEST.in 2022-06-08 11:33:29.000000000 +0200 @@ -3,5 +3,6 @@ include *.md include LICENSE include tox.ini +include pyproject.toml prune .travis prune debian diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-canonicaljson-1.5.0/README.rst new/python-canonicaljson-1.6.2/README.rst --- old/python-canonicaljson-1.5.0/README.rst 2021-10-08 18:24:57.000000000 +0200 +++ new/python-canonicaljson-1.6.2/README.rst 2022-06-08 11:33:29.000000000 +0200 @@ -17,7 +17,7 @@ * Encodes the JSON as UTF-8. * Can encode ``frozendict`` immutable dictionaries. -Supports Python versions 3.5 and newer. +Supports Python versions 3.7 and newer. .. _`RFC 7159`: https://tools.ietf.org/html/rfc7159 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-canonicaljson-1.5.0/canonicaljson.py new/python-canonicaljson-1.6.2/canonicaljson.py --- old/python-canonicaljson-1.5.0/canonicaljson.py 2021-10-08 18:24:57.000000000 +0200 +++ new/python-canonicaljson-1.6.2/canonicaljson.py 2022-06-08 11:33:29.000000000 +0200 @@ -16,35 +16,53 @@ # limitations under the License. import platform +from typing import Any, Generator, Optional, Type -from frozendict import frozendict - -__version__ = "1.5.0" - - -def _default(obj): # pragma: no cover - if type(obj) is frozendict: - # fishing the protected dict out of the object is a bit nasty, - # but we don't really want the overhead of copying the dict. - try: - return obj._dict - except AttributeError: - # When the C implementation of frozendict is used, - # there isn't a `_dict` attribute with a dict - # so we resort to making a copy of the frozendict - return dict(obj) +try: + from typing import Protocol +except ImportError: # pragma: no cover + from typing_extensions import Protocol # type: ignore[misc] + +frozendict_type: Optional[Type[Any]] +try: + from frozendict import frozendict as frozendict_type +except ImportError: + frozendict_type = None # pragma: no cover + +__version__ = "1.6.2" + + +def _default(obj: object) -> object: # pragma: no cover + if type(obj) is frozendict_type: + # If frozendict is available and used, cast `obj` into a dict + return dict(obj) # type: ignore[call-overload] raise TypeError( "Object of type %s is not JSON serializable" % obj.__class__.__name__ ) +class Encoder(Protocol): # pragma: no cover + def encode(self, data: object) -> str: + pass + + def iterencode(self, data: object) -> Generator[str, None, None]: + pass + + def __call__(self, *args: Any, **kwargs: Any) -> "Encoder": + pass + + +class JsonLibrary(Protocol): + JSONEncoder: Encoder + + # Declare these in the module scope, but they get configured in # set_json_library. -_canonical_encoder = None -_pretty_encoder = None +_canonical_encoder: Encoder = None # type: ignore[assignment] +_pretty_encoder: Encoder = None # type: ignore[assignment] -def set_json_library(json_lib): +def set_json_library(json_lib: JsonLibrary) -> None: """ Set the underlying JSON library that canonicaljson uses to json_lib. @@ -71,55 +89,44 @@ ) -def encode_canonical_json(json_object): - """Encodes the shortest UTF-8 JSON encoding with dictionary keys - lexicographically sorted by unicode code point. - - Args: - json_object (dict): The JSON object to encode. - - Returns: - bytes encoding the JSON object""" - s = _canonical_encoder.encode(json_object) - return s.encode("utf-8") - +def encode_canonical_json(data: object) -> bytes: + """Encodes the given `data` as a UTF-8 canonical JSON bytestring. -def iterencode_canonical_json(json_object): - """Encodes the shortest UTF-8 JSON encoding with dictionary keys + This encoding is the shortest possible. Dictionary keys are lexicographically sorted by unicode code point. + """ + s = _canonical_encoder.encode(data) + return s.encode("utf-8") - Args: - json_object (dict): The JSON object to encode. - Returns: - generator which yields bytes encoding the JSON object""" - for chunk in _canonical_encoder.iterencode(json_object): - yield chunk.encode("utf-8") +def iterencode_canonical_json(data: object) -> Generator[bytes, None, None]: + """Iteratively encodes the given `data` as a UTF-8 canonical JSON bytestring. + This yields one or more bytestrings; concatenating them all together yields the + full encoding of `data`. Building up the encoding gradually in this way allows us to + encode large pieces of `data` without blocking other tasks. -def encode_pretty_printed_json(json_object): + This encoding is the shortest possible. Dictionary keys are + lexicographically sorted by unicode code point. """ - Encodes the JSON object dict as human readable UTF-8 bytes. - - Args: - json_object (dict): The JSON object to encode. - - Returns: - bytes encoding the JSON object""" + for chunk in _canonical_encoder.iterencode(data): + yield chunk.encode("utf-8") - return _pretty_encoder.encode(json_object).encode("utf-8") +def encode_pretty_printed_json(data: object) -> bytes: + """Encodes the given `data` as a UTF-8 human-readable JSON bytestring.""" -def iterencode_pretty_printed_json(json_object): - """Encodes the JSON object dict as human readable UTF-8 bytes. + return _pretty_encoder.encode(data).encode("utf-8") - Args: - json_object (dict): The JSON object to encode. - Returns: - generator which yields bytes encoding the JSON object""" +def iterencode_pretty_printed_json(data: object) -> Generator[bytes, None, None]: + """Iteratively encodes the given `data` as a UTF-8 human-readable JSON bytestring. - for chunk in _pretty_encoder.iterencode(json_object): + This yields one or more bytestrings; concatenating them all together yields the + full encoding of `data`. Building up the encoding gradually in this way allows us to + encode large pieces of `data` without blocking other tasks. + """ + for chunk in _pretty_encoder.iterencode(data): yield chunk.encode("utf-8") @@ -134,7 +141,7 @@ # # Note that it seems performance is on par or better using json from the # standard library as of Python 3.7. - import simplejson as json + import simplejson as json # type: ignore[no-redef] # Set the JSON library to the backwards compatible version. set_json_library(json) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-canonicaljson-1.5.0/pyproject.toml new/python-canonicaljson-1.6.2/pyproject.toml --- old/python-canonicaljson-1.5.0/pyproject.toml 1970-01-01 01:00:00.000000000 +0100 +++ new/python-canonicaljson-1.6.2/pyproject.toml 2022-06-08 11:33:29.000000000 +0200 @@ -0,0 +1,6 @@ +[tool.mypy] +show_error_codes = true +strict = true + +files = ["."] +exclude = "setup.py" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-canonicaljson-1.5.0/setup.py new/python-canonicaljson-1.6.2/setup.py --- old/python-canonicaljson-1.5.0/setup.py 2021-10-08 18:24:57.000000000 +0200 +++ new/python-canonicaljson-1.6.2/setup.py 2022-06-08 11:33:29.000000000 +0200 @@ -49,8 +49,13 @@ # simplerjson versions before 3.14.0 had a bug with some characters # (e.g. \u2028) if ensure_ascii was set to false. "simplejson>=3.14.0", - "frozendict>=1.0", + # typing.Protocol was only added to the stdlib in Python 3.8 + "typing_extensions>=4.0.0; python_version < '3.8'", ], + extras_require={ + # frozendict support can be enabled using the `canonicaljson[frozendict]` syntax + "frozendict": ["frozendict>=1.0"], + }, zip_safe=True, long_description=read_file(("README.rst",)), keywords="json", @@ -58,7 +63,7 @@ author_email="t...@matrix.org", url="https://github.com/matrix-org/python-canonicaljson", license="Apache License, Version 2.0", - python_requires="~=3.5", + python_requires="~=3.7", classifiers=[ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-canonicaljson-1.5.0/test_canonicaljson.py new/python-canonicaljson-1.6.2/test_canonicaljson.py --- old/python-canonicaljson-1.5.0/test_canonicaljson.py 2021-10-08 18:24:57.000000000 +0200 +++ new/python-canonicaljson-1.6.2/test_canonicaljson.py 2022-06-08 11:33:29.000000000 +0200 @@ -14,24 +14,24 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + from math import inf, nan from canonicaljson import ( encode_canonical_json, encode_pretty_printed_json, + frozendict_type, iterencode_canonical_json, iterencode_pretty_printed_json, set_json_library, ) -from frozendict import frozendict - import unittest from unittest import mock class TestCanonicalJson(unittest.TestCase): - def test_encode_canonical(self): + def test_encode_canonical(self) -> None: self.assertEqual(encode_canonical_json({}), b"{}") # ctrl-chars should be encoded. @@ -68,7 +68,7 @@ # Iteratively encoding should work. self.assertEqual(list(iterencode_canonical_json({})), [b"{}"]) - def test_ascii(self): + def test_ascii(self) -> None: """ Ensure the proper ASCII characters are escaped. @@ -95,10 +95,10 @@ # And other characters are passed unescaped. unescaped = [0x20, 0x21] + list(range(0x23, 0x5C)) + list(range(0x5D, 0x7E)) for c in unescaped: - c = chr(c) - self.assertEqual(encode_canonical_json(c), b'"' + c.encode("ascii") + b'"') + s = chr(c) + self.assertEqual(encode_canonical_json(s), b'"' + s.encode("ascii") + b'"') - def test_encode_pretty_printed(self): + def test_encode_pretty_printed(self) -> None: self.assertEqual(encode_pretty_printed_json({}), b"{}") self.assertEqual(list(iterencode_pretty_printed_json({})), [b"{}"]) @@ -108,16 +108,23 @@ b'{\n "la merde amus\xc3\xa9e": "\xF0\x9F\x92\xA9"\n}', ) - def test_frozen_dict(self): + @unittest.skipIf( + frozendict_type is None, + "If `frozendict` is not available, skip test", + ) + def test_frozen_dict(self) -> None: + # For mypy's benefit: + assert frozendict_type is not None self.assertEqual( - encode_canonical_json(frozendict({"a": 1})), + encode_canonical_json(frozendict_type({"a": 1})), b'{"a":1}', ) self.assertEqual( - encode_pretty_printed_json(frozendict({"a": 1})), b'{\n "a": 1\n}' + encode_pretty_printed_json(frozendict_type({"a": 1})), + b'{\n "a": 1\n}', ) - def test_unknown_type(self): + def test_unknown_type(self) -> None: class Unknown(object): pass @@ -128,7 +135,7 @@ with self.assertRaises(Exception): encode_pretty_printed_json(unknown_object) - def test_invalid_float_values(self): + def test_invalid_float_values(self) -> None: """Infinity/-Infinity/NaN are not allowed in canonicaljson.""" with self.assertRaises(ValueError): @@ -149,7 +156,7 @@ with self.assertRaises(ValueError): encode_pretty_printed_json(nan) - def test_set_json(self): + def test_set_json(self) -> None: """Ensure that changing the underlying JSON implementation works.""" mock_json = mock.Mock(spec=["JSONEncoder"]) mock_json.JSONEncoder.return_value.encode.return_value = "sentinel" @@ -158,6 +165,6 @@ self.assertEqual(encode_canonical_json({}), b"sentinel") finally: # Reset the JSON library to whatever was originally set. - from canonicaljson import json + from canonicaljson import json # type: ignore[attr-defined] set_json_library(json) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-canonicaljson-1.5.0/tox.ini new/python-canonicaljson-1.6.2/tox.ini --- old/python-canonicaljson-1.5.0/tox.ini 2021-10-08 18:24:57.000000000 +0200 +++ new/python-canonicaljson-1.6.2/tox.ini 2022-06-08 11:33:29.000000000 +0200 @@ -1,5 +1,5 @@ [tox] -envlist = packaging, pep8, py35, py36, py37, py38, py39, py310, pypy3 +envlist = packaging, pep8, black, py37, py38, py39, py310, pypy3 [testenv] deps = @@ -16,13 +16,23 @@ commands = check-manifest [testenv:pep8] -basepython = python3.6 +basepython = python3.7 deps = flake8 commands = flake8 . [testenv:black] -basepython = python3.6 +basepython = python3.7 deps = - black + black==21.9b0 + # Workaround black+click incompatability, see https://github.com/psf/black/issues/2964 + click==8.0.4 commands = python -m black --check --diff . + +[testenv:mypy] +deps = + mypy==0.942 + types-frozendict==2.0.8 + types-simplejson==3.17.5 + types-setuptools==57.4.14 +commands = mypy