Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-jsonlines for openSUSE:Factory checked in at 2023-12-08 22:33:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-jsonlines (Old) and /work/SRC/openSUSE:Factory/.python-jsonlines.new.25432 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-jsonlines" Fri Dec 8 22:33:18 2023 rev:5 rq:1132063 version:4.0.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-jsonlines/python-jsonlines.changes 2023-07-01 23:18:20.410364219 +0200 +++ /work/SRC/openSUSE:Factory/.python-jsonlines.new.25432/python-jsonlines.changes 2023-12-08 22:34:13.092779021 +0100 @@ -1,0 +2,8 @@ +Fri Dec 8 09:47:50 UTC 2023 - Dirk Müller <dmuel...@suse.com> + +- update to 4.0.0: + * use âorjsonâ or âujsonâ for reading if available + * drop support for end-of-life Python versions; this package is now + Python 3.8+ only. + +------------------------------------------------------------------- Old: ---- 3.1.0.tar.gz New: ---- 4.0.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-jsonlines.spec ++++++ --- /var/tmp/diff_new_pack.1yg1ZV/_old 2023-12-08 22:34:14.472829799 +0100 +++ /var/tmp/diff_new_pack.1yg1ZV/_new 2023-12-08 22:34:14.480830093 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-jsonlines # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -20,18 +20,21 @@ %global skip_python2 1 %{?sle15_python_module_pythons} Name: python-jsonlines -Version: 3.1.0 +Version: 4.0.0 Release: 0 Summary: Library with helpers for the jsonlines file format License: BSD-3-Clause Group: Development/Languages/Python URL: https://github.com/wbolster/jsonlines Source: https://github.com/wbolster/jsonlines/archive/%{version}.tar.gz +BuildRequires: %{python_module devel >= 3.8} BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module ujson} BuildRequires: fdupes BuildRequires: python-rpm-macros BuildArch: noarch +Requires: python-ujson %python_subpackages %description ++++++ 3.1.0.tar.gz -> 4.0.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonlines-3.1.0/.readthedocs.yaml new/jsonlines-4.0.0/.readthedocs.yaml --- old/jsonlines-3.1.0/.readthedocs.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/jsonlines-4.0.0/.readthedocs.yaml 2023-09-01 14:31:39.000000000 +0200 @@ -0,0 +1,14 @@ +--- +version: "2" + +build: + os: "ubuntu-22.04" + tools: + python: "3.11" + +python: + install: + - path: . + +sphinx: + configuration: doc/conf.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonlines-3.1.0/.travis.yml new/jsonlines-4.0.0/.travis.yml --- old/jsonlines-3.1.0/.travis.yml 2022-07-01 18:35:18.000000000 +0200 +++ new/jsonlines-4.0.0/.travis.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,27 +0,0 @@ -dist: xenial -group: travis_latest - -branches: - only: - - master - -language: python - -matrix: - include: - - python: "3.9" - env: TOXENV=linters - - python: "3.9" - env: TOXENV=py39 - - python: "3.8" - env: TOXENV=py38 - - python: "3.7" - env: TOXENV=py37 - - python: "3.6" - env: TOXENV=py36 - -install: - - pip install --upgrade tox - -script: - - tox diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonlines-3.1.0/README.rst new/jsonlines-4.0.0/README.rst --- old/jsonlines-3.1.0/README.rst 2022-07-01 18:35:18.000000000 +0200 +++ new/jsonlines-4.0.0/README.rst 2023-09-01 14:31:39.000000000 +0200 @@ -1,6 +1,3 @@ -.. image:: https://travis-ci.org/wbolster/jsonlines.svg?branch=master - :target: https://travis-ci.org/wbolster/jsonlines - .. image:: https://pepy.tech/badge/jsonlines :target: https://pepy.tech/project/jsonlines diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonlines-3.1.0/doc/index.rst new/jsonlines-4.0.0/doc/index.rst --- old/jsonlines-3.1.0/doc/index.rst 2022-07-01 18:35:18.000000000 +0200 +++ new/jsonlines-4.0.0/doc/index.rst 2023-09-01 14:31:39.000000000 +0200 @@ -22,6 +22,16 @@ Features ======== +* Sensible behaviour for most use cases + + * transparently handles ``str`` and ``bytes``, both for input and output + * supports multiple JSON libraries, e.g. ``json`` (standard library), ``orjson``, ``ujson`` + * transparently handles UTF-8 BOM (if present) + * useful error messages + * prevents gotchas, e.g. uses standard-compliant line breaking, unlike `str.splitlines`_ + + .. _str.splitlines: https://docs.python.org/3/library/stdtypes.html#str.splitlines + * Convenient :py:func:`~jsonlines.open()` function * makes simple cases trivial to write @@ -62,7 +72,7 @@ pip install jsonlines -The supported Python versions are 3.6+. +The supported Python versions are 3.8+. User guide @@ -179,6 +189,16 @@ Version history =============== +* 4.0.0, released at 2023-09-01 + + * use âorjsonâ or âujsonâ for reading if available + (`#81 <https://github.com/wbolster/jsonlines/pull/81>`_) + + * drop support for end-of-life Python versions; this package is now + Python 3.8+ only. + (`#80 <https://github.com/wbolster/jsonlines/pull/80>`_, + `#80 <https://github.com/wbolster/jsonlines/pull/85>`_) + * 3.1.0, released at 2022-07-01 * Return number of chars/bytes written by :py:meth:`Writer.write()` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonlines-3.1.0/jsonlines/jsonlines.py new/jsonlines-4.0.0/jsonlines/jsonlines.py --- old/jsonlines-3.1.0/jsonlines/jsonlines.py 2022-07-01 18:35:18.000000000 +0200 +++ new/jsonlines-4.0.0/jsonlines/jsonlines.py 2023-09-01 14:31:39.000000000 +0200 @@ -8,7 +8,6 @@ import io import json import os -import sys import types import typing from typing import ( @@ -18,6 +17,7 @@ Iterable, Iterator, List, + Literal, Optional, Tuple, Type, @@ -27,13 +27,21 @@ overload, ) -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal # pragma: no cover - import attr +orjson: Optional[types.ModuleType] +try: + import orjson +except ImportError: + orjson = None + +ujson: Optional[types.ModuleType] +try: + import ujson +except ImportError: + ujson = None + + VALID_TYPES = { bool, dict, @@ -73,12 +81,22 @@ TRW = TypeVar("TRW", bound="ReaderWriterBase") -default_loads = json.loads +# Default to using the fastest JSON library for reading, falling back to the +# standard library (always available) if none are installed. +if orjson is not None: + default_loads = orjson.loads +elif ujson is not None: + default_loads = ujson.loads +else: + default_loads = json.loads +# For writing, use the stdlib. Other packages may be faster but their behaviour +# (supported types etc.) and output (whitespace etc.) are not the same as the +# stdlib json module, so this should be opt-in via the âdumps=â arg. def default_dumps(obj: Any) -> str: """ - Fake dumps() function to use as a default marker. + Fake ``dumps()`` function to use as a default marker. """ raise NotImplementedError # pragma: no cover @@ -481,20 +499,18 @@ self._fp_is_binary = True else: try: - self._fp.write("") # type: ignore[arg-type] + self._fp.write("") # type: ignore[call-overload] except TypeError: self._fp_is_binary = True else: self._fp_is_binary = False if self._dumps is default_dumps: - encoder_kwargs: Dict[str, Any] = dict( + self._dumps = json.JSONEncoder( ensure_ascii=False, + separators=(",", ":") if self._compact else (", ", ": "), sort_keys=self._sort_keys, - ) - if self._compact: - encoder_kwargs.update(separators=(",", ":")) - self._dumps = json.JSONEncoder(**encoder_kwargs).encode + ).encode # Detect if str-to-bytes conversion (or vice versa) is needed for the # combination of this file-like object and the used dumps() callable. @@ -528,7 +544,7 @@ fp = self._fp fp.write(line) # type: ignore[arg-type] - fp.write(b"\n" if self._fp_is_binary else "\n") # type: ignore[arg-type] + fp.write(b"\n" if self._fp_is_binary else "\n") # type: ignore[call-overload] if self._flush: fp.flush() @@ -598,12 +614,12 @@ """ Open a jsonlines file for reading or writing. - This is a convenience function that opens a file, and wraps it in - either a :py:class:`Reader` or :py:class:`Writer` instance, - depending on the specified `mode`. + This is a convenience function to open a file and wrap it in either a + :py:class:`Reader` or :py:class:`Writer` instance, depending on the + specified `mode`. - Any additional keyword arguments will be passed on to the reader and - writer: see their documentation for available options. + Additional keyword arguments will be passed on to the reader and writer; + see their documentation for available options. The resulting reader or writer must be closed after use by the caller, which will also close the opened file. This can be done by @@ -617,7 +633,7 @@ :param file: name or âpath-like objectâ of the file to open :param mode: whether to open the file for reading (``r``), - writing (``w``) or appending (``a``). + writing (``w``), appending (``a``), or exclusive creation (``x``). """ if mode not in {"r", "w", "a", "x"}: raise ValueError("'mode' must be either 'r', 'w', 'a', or 'x'") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonlines-3.1.0/requirements-dev.txt new/jsonlines-4.0.0/requirements-dev.txt --- old/jsonlines-3.1.0/requirements-dev.txt 2022-07-01 18:35:18.000000000 +0200 +++ new/jsonlines-4.0.0/requirements-dev.txt 2023-09-01 14:31:39.000000000 +0200 @@ -1,6 +1,9 @@ black flake8 mypy +orjson pytest>=3 pytest-cov sphinx +types-ujson +ujson diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonlines-3.1.0/setup.cfg new/jsonlines-4.0.0/setup.cfg --- old/jsonlines-3.1.0/setup.cfg 2022-07-01 18:35:18.000000000 +0200 +++ new/jsonlines-4.0.0/setup.cfg 2023-09-01 14:31:39.000000000 +0200 @@ -1,6 +1,6 @@ [metadata] name = jsonlines -version = 3.1.0 +version = 4.0.0 author = wouter bolsterlee author_email = wou...@bolsterl.ee license = BSD @@ -23,10 +23,9 @@ [options] packages = jsonlines -python_requires = >=3.6 +python_requires = >=3.8 install_requires = attrs>=19.2.0 - typing_extensions; python_version < "3.8" [options.package_data] jsonlines = py.typed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonlines-3.1.0/tests/test_jsonlines.py new/jsonlines-4.0.0/tests/test_jsonlines.py --- old/jsonlines-3.1.0/tests/test_jsonlines.py 2022-07-01 18:35:18.000000000 +0200 +++ new/jsonlines-4.0.0/tests/test_jsonlines.py 2023-09-01 14:31:39.000000000 +0200 @@ -16,6 +16,19 @@ SAMPLE_TEXT = SAMPLE_BYTES.decode("utf-8") +def is_json_decode_error(exc: object) -> bool: + if type(exc).__module__ == "ujson": + # The ujson package has its own ujson.JSONDecodeError; because of the + # line above this function also works if it's not installed. + import ujson + + return isinstance(exc, ujson.JSONDecodeError) + else: + # Otherwise, this should be a stdlib json.JSONDecodeError, which also + # works for orjson since orjson.JSONDecodeError inherits from it. + return isinstance(exc, json.JSONDecodeError) + + def test_reader() -> None: fp = io.BytesIO(SAMPLE_BYTES) with jsonlines.Reader(fp) as reader: @@ -79,7 +92,7 @@ exc = excinfo.value assert "invalid json" in str(exc) - assert isinstance(exc.__cause__, json.JSONDecodeError) + assert is_json_decode_error(exc.__cause__) def test_writer_text() -> None: @@ -122,7 +135,7 @@ exc = excinfo.value assert "invalid json" in str(exc) assert exc.line == data - assert isinstance(exc.__cause__, json.JSONDecodeError) + assert is_json_decode_error(exc.__cause__) def test_skip_invalid() -> None: @@ -173,7 +186,7 @@ reader.read(type=int) exc = excinfo.value assert "does not match requested type" in str(exc) - assert exc.line == 'true' + assert exc.line == "true" with pytest.raises(jsonlines.InvalidLineError) as excinfo: reader.read(type=float) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonlines-3.1.0/tests/test_typing.py new/jsonlines-4.0.0/tests/test_typing.py --- old/jsonlines-3.1.0/tests/test_typing.py 2022-07-01 18:35:18.000000000 +0200 +++ new/jsonlines-4.0.0/tests/test_typing.py 2023-09-01 14:31:39.000000000 +0200 @@ -20,7 +20,6 @@ def something_with_reader() -> None: - reader: jsonlines.Reader reader = jsonlines.Reader(io.StringIO()) reader = jsonlines.Reader(io.BytesIO()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonlines-3.1.0/tox.ini new/jsonlines-4.0.0/tox.ini --- old/jsonlines-3.1.0/tox.ini 2022-07-01 18:35:18.000000000 +0200 +++ new/jsonlines-4.0.0/tox.ini 2023-09-01 14:31:39.000000000 +0200 @@ -1,12 +1,12 @@ [tox] -envlist = py310,py39,py38,py37,py36,linters +envlist = py311,py310,py39,py38,linters [testenv] deps = -rrequirements-dev.txt commands = pytest {posargs} tests/ [testenv:linters] -basepython = python3.9 +basepython = python3.11 deps = -rrequirements-dev.txt commands = flake8 jsonlines/ tests/