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 2021-11-08 17:24:34
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-jsonlines (Old)
and /work/SRC/openSUSE:Factory/.python-jsonlines.new.1890 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-jsonlines"
Mon Nov 8 17:24:34 2021 rev:2 rq:930117 version:2.0.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-jsonlines/python-jsonlines.changes
2018-08-31 10:46:39.739363437 +0200
+++
/work/SRC/openSUSE:Factory/.python-jsonlines.new.1890/python-jsonlines.changes
2021-11-08 17:25:21.996739896 +0100
@@ -1,0 +2,6 @@
+Mon Nov 8 10:08:24 UTC 2021 - Dirk M??ller <[email protected]>
+
+- update to 2.0.0:
+ * drop support for python versions older than 3.6
+
+-------------------------------------------------------------------
Old:
----
1.2.0.tar.gz
New:
----
2.0.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-jsonlines.spec ++++++
--- /var/tmp/diff_new_pack.q584Cl/_old 2021-11-08 17:25:22.588740285 +0100
+++ /var/tmp/diff_new_pack.q584Cl/_new 2021-11-08 17:25:22.592740288 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-jsonlines
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,13 +12,14 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
+%global skip_python2 1
Name: python-jsonlines
-Version: 1.2.0
+Version: 2.0.0
Release: 0
Summary: Library with helpers for the jsonlines file format
License: BSD-3-Clause
++++++ 1.2.0.tar.gz -> 2.0.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonlines-1.2.0/.editorconfig
new/jsonlines-2.0.0/.editorconfig
--- old/jsonlines-1.2.0/.editorconfig 1970-01-01 01:00:00.000000000 +0100
+++ new/jsonlines-2.0.0/.editorconfig 2021-01-04 17:03:18.000000000 +0100
@@ -0,0 +1,8 @@
+root = true
+
+[*.py]
+charset = utf-8
+indent_style = space
+indent_size = 4
+insert_final_newline = true
+end_of_line = lf
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonlines-1.2.0/.travis.yml
new/jsonlines-2.0.0/.travis.yml
--- old/jsonlines-1.2.0/.travis.yml 2017-08-17 12:08:20.000000000 +0200
+++ new/jsonlines-2.0.0/.travis.yml 2021-01-04 17:03:18.000000000 +0100
@@ -1,11 +1,27 @@
+dist: xenial
+group: travis_latest
+
+branches:
+ only:
+ - master
+
language: python
-python:
- - "2.7"
- - "3.3"
- - "3.4"
- - "3.5"
- - "3.6"
+
+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 .
- - pip install -r requirements-dev.txt
-script: pytest
+ - pip install --upgrade tox
+
+script:
+ - tox
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonlines-1.2.0/README.rst
new/jsonlines-2.0.0/README.rst
--- old/jsonlines-1.2.0/README.rst 2017-08-17 12:08:20.000000000 +0200
+++ new/jsonlines-2.0.0/README.rst 2021-01-04 17:03:18.000000000 +0100
@@ -1,3 +1,12 @@
+.. 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
+
+.. image:: https://pepy.tech/badge/jsonlines/month
+ :target: https://pepy.tech/project/jsonlines
+
=========
jsonlines
=========
@@ -14,5 +23,3 @@
* Source code and issue tracker: https://github.com/wbolster/jsonlines
-.. image:: https://travis-ci.org/wbolster/jsonlines.svg?branch=master
- :target: https://travis-ci.org/wbolster/jsonlines
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonlines-1.2.0/doc/conf.py
new/jsonlines-2.0.0/doc/conf.py
--- old/jsonlines-1.2.0/doc/conf.py 2017-08-17 12:08:20.000000000 +0200
+++ new/jsonlines-2.0.0/doc/conf.py 2021-01-04 17:03:18.000000000 +0100
@@ -1,7 +1,7 @@
extensions = [
- 'sphinx.ext.autodoc',
+ "sphinx.ext.autodoc",
]
-master_doc = 'index'
-project = 'jsonlines'
-copyright = 'Wouter Bolsterlee'
+master_doc = "index"
+project = "jsonlines"
+copyright = "wouter bolsterlee"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonlines-1.2.0/doc/index.rst
new/jsonlines-2.0.0/doc/index.rst
--- old/jsonlines-1.2.0/doc/index.rst 2017-08-17 12:08:20.000000000 +0200
+++ new/jsonlines-2.0.0/doc/index.rst 2021-01-04 17:03:18.000000000 +0100
@@ -62,7 +62,7 @@
pip install jsonlines
-The supported Python versions are 3.3+ and Python 2.7.
+The supported Python versions are 3.6+.
User guide
@@ -171,7 +171,7 @@
Contributing
============
-The source code and issue tracker for this package can be found on Github:
+The source code and issue tracker for this package can be found on GitHub:
https://github.com/wbolster/jsonlines
@@ -179,6 +179,13 @@
Version history
===============
+* 2.0.0, released at 2021-01-04
+
+ * drop support for end-of-life Python versions; this package is now
+ Python 3.6+ only.
+ (`#54 <https://github.com/wbolster/jsonlines/pull/54>`_,
+ `#51 <https://github.com/wbolster/jsonlines/pull/51>`_)
+
* 1.2.0, released at 2017-08-17
* allow ``mode='a'`` in :py:func:`~jsonlines.open()`
@@ -187,8 +194,8 @@
* 1.1.3, released at 2017-07-19
- * fix incomplete iteration when given list containing empty strings
- (`#30 <https://github.com/wbolster/jsonlines/issues/30>`_)
+ * fix incomplete iteration when given list containing empty strings
+ (`#30 <https://github.com/wbolster/jsonlines/issues/30>`_)
* 1.1.2, released at 2017-06-26
@@ -212,7 +219,7 @@
* 1.0.0, released at 2016-10-05
- * minimum python versions are python 3.4+ and python2.7+
+ * minimum Python versions are Python 3.4+ and Python 2.7+
* implemented lots of configuration options
* add proper exceptions handling
* add proper documentation
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonlines-1.2.0/jsonlines/__init__.py
new/jsonlines-2.0.0/jsonlines/__init__.py
--- old/jsonlines-1.2.0/jsonlines/__init__.py 2017-08-17 12:08:20.000000000
+0200
+++ new/jsonlines-2.0.0/jsonlines/__init__.py 2021-01-04 17:03:18.000000000
+0100
@@ -3,10 +3,18 @@
"""
# expose only public api
-from .jsonlines import ( # noqa
+from .jsonlines import (
+ Error,
+ InvalidLineError,
Reader,
Writer,
open,
- Error,
- InvalidLineError,
)
+
+__all__ = [
+ "Error",
+ "InvalidLineError",
+ "Reader",
+ "Writer",
+ "open",
+]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonlines-1.2.0/jsonlines/jsonlines.py
new/jsonlines-2.0.0/jsonlines/jsonlines.py
--- old/jsonlines-1.2.0/jsonlines/jsonlines.py 2017-08-17 12:08:20.000000000
+0200
+++ new/jsonlines-2.0.0/jsonlines/jsonlines.py 2021-01-04 17:03:18.000000000
+0100
@@ -2,26 +2,27 @@
jsonlines implementation
"""
-import numbers
-import io
+import builtins
import json
-
-import six
+import numbers
-TYPE_MAPPING = {
- dict: dict,
- list: list,
- str: six.text_type,
- int: six.integer_types,
- float: float,
- numbers.Number: numbers.Number,
- bool: bool,
+VALID_TYPES = {
+ bool,
+ dict,
+ float,
+ int,
+ list,
+ numbers.Number,
+ str,
}
class Error(Exception):
- """Base error class."""
+ """
+ Base error class.
+ """
+
pass
@@ -39,6 +40,7 @@
This class subclasses both ``jsonlines.Error`` and the built-in
``ValueError``.
"""
+
#: The invalid line
line = None
@@ -46,16 +48,17 @@
lineno = None
def __init__(self, msg, line, lineno):
- msg = "{} (line {})".format(msg, lineno)
+ msg = f"{msg} (line {lineno})"
self.line = line.rstrip()
self.lineno = lineno
- super(InvalidLineError, self).__init__(msg)
+ super().__init__(msg)
-class ReaderWriterBase(object):
+class ReaderWriterBase:
"""
Base class with shared behaviour for both the reader and writer.
"""
+
def close(self):
"""
Close this reader/writer.
@@ -71,15 +74,14 @@
self._fp.close()
def __repr__(self):
- name = getattr(self._fp, 'name', None)
+ name = getattr(self._fp, "name", None)
if name:
wrapping = repr(name)
else:
- wrapping = '<{} at 0x{:x}>'.format(
- type(self._fp).__name__,
- id(self._fp))
- return '<jsonlines.{} at 0x{:x} wrapping {}>'.format(
- type(self).__name__, id(self), wrapping)
+ wrapping = "<{} at 0x{:x}>".format(type(self._fp).__name__,
id(self._fp))
+ return "<jsonlines.{} at 0x{:x} wrapping {}>".format(
+ type(self).__name__, id(self), wrapping
+ )
def __enter__(self):
return self
@@ -107,6 +109,7 @@
:param file-like iterable: iterable yielding lines as strings
:param callable loads: custom json decoder callable
"""
+
def __init__(self, iterable, loads=None):
self._fp = iterable
self._should_close_fp = False
@@ -135,8 +138,8 @@
containing only whitespace are silently skipped.
"""
if self._closed:
- raise RuntimeError('reader is closed')
- if type is not None and type not in TYPE_MAPPING:
+ raise RuntimeError("reader is closed")
+ if type is not None and type not in VALID_TYPES:
raise ValueError("invalid type specified")
try:
@@ -144,43 +147,42 @@
while skip_empty and not line.rstrip():
lineno, line = next(self._line_iter)
except StopIteration:
- six.raise_from(EOFError, None)
+ raise EOFError from None
- if isinstance(line, six.binary_type):
+ if isinstance(line, bytes):
try:
- line = line.decode('utf-8')
+ line = line.decode("utf-8")
except UnicodeDecodeError as orig_exc:
exc = InvalidLineError(
- "line is not valid utf-8: {}".format(orig_exc),
- line, lineno)
- six.raise_from(exc, orig_exc)
+ f"line is not valid utf-8: {orig_exc}", line, lineno
+ )
+ raise exc from orig_exc
try:
value = self._loads(line)
except ValueError as orig_exc:
exc = InvalidLineError(
- "line contains invalid json: {}".format(orig_exc),
- line, lineno)
- six.raise_from(exc, orig_exc)
+ f"line contains invalid json: {orig_exc}", line, lineno
+ )
+ raise exc from orig_exc
if value is None:
if allow_none:
return None
- raise InvalidLineError(
- "line contains null value", line, lineno)
+ raise InvalidLineError("line contains null value", line, lineno)
if type is not None:
- valid = isinstance(value, TYPE_MAPPING[type])
+ valid = isinstance(value, type)
if type in (int, numbers.Number):
valid = valid and not isinstance(value, bool)
if not valid:
raise InvalidLineError(
- "line does not match requested type", line, lineno)
+ "line does not match requested type", line, lineno
+ )
return value
- def iter(self, type=None, allow_none=False, skip_empty=False,
- skip_invalid=False):
+ def iter(self, type=None, allow_none=False, skip_empty=False,
skip_invalid=False):
"""
Iterate over all lines.
@@ -199,9 +201,8 @@
while True:
try:
yield self.read(
- type=type,
- allow_none=allow_none,
- skip_empty=skip_empty)
+ type=type, allow_none=allow_none, skip_empty=skip_empty
+ )
except InvalidLineError:
if not skip_invalid:
raise
@@ -243,18 +244,18 @@
:param bool flush: whether to flush the file-like object after
writing each line
"""
- def __init__(
- self, fp, compact=False, sort_keys=False, dumps=None, flush=False):
+
+ def __init__(self, fp, compact=False, sort_keys=False, dumps=None,
flush=False):
self._closed = False
try:
- fp.write(u'')
+ fp.write("")
self._fp_is_binary = False
except TypeError:
self._fp_is_binary = True
if dumps is None:
encoder_kwargs = dict(ensure_ascii=False, sort_keys=sort_keys)
if compact:
- encoder_kwargs.update(separators=(',', ':'))
+ encoder_kwargs.update(separators=(",", ":"))
dumps = json.JSONEncoder(**encoder_kwargs).encode
self._fp = fp
self._should_close_fp = False
@@ -268,22 +269,15 @@
:param obj: the object to encode and write
"""
if self._closed:
- raise RuntimeError('writer is closed')
+ raise RuntimeError("writer is closed")
line = self._dumps(obj)
- # On Python 2, the JSON module has the nasty habit of returning
- # either a byte string or unicode string, depending on whether
- # the serialised structure can be encoded using ASCII only, so
- # this means this code needs to handle all combinations.
if self._fp_is_binary:
- if not isinstance(line, six.binary_type):
- line = line.encode('utf-8')
+ line = line.encode("utf-8")
self._fp.write(line)
- self._fp.write(b'\n')
+ self._fp.write(b"\n")
else:
- if not isinstance(line, six.text_type):
- line = line.decode('ascii') # For Python 2.
self._fp.write(line)
- self._fp.write(u'\n')
+ self._fp.write("\n")
if self._flush:
self._fp.flush()
@@ -297,7 +291,7 @@
self.write(obj)
-def open(name, mode='r', **kwargs):
+def open(name, mode="r", **kwargs):
"""
Open a jsonlines file for reading or writing.
@@ -321,12 +315,12 @@
:param file-like fp: name of the file to open
:param str mode: whether to open the file for reading (``r``),
writing (``w``) or appending (``a``).
- :param \*\*kwargs: additional arguments, forwarded to the reader or writer
+ :param **kwargs: additional arguments, forwarded to the reader or writer
"""
- if mode not in {'r', 'w', 'a'}:
+ if mode not in {"r", "w", "a"}:
raise ValueError("'mode' must be either 'r', 'w', or 'a'")
- fp = io.open(name, mode=mode + 't', encoding='utf-8')
- if mode == 'r':
+ fp = builtins.open(name, mode=mode + "t", encoding="utf-8")
+ if mode == "r":
instance = Reader(fp, **kwargs)
else:
instance = Writer(fp, **kwargs)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonlines-1.2.0/requirements-dev.txt
new/jsonlines-2.0.0/requirements-dev.txt
--- old/jsonlines-1.2.0/requirements-dev.txt 2017-08-17 12:08:20.000000000
+0200
+++ new/jsonlines-2.0.0/requirements-dev.txt 2021-01-04 17:03:18.000000000
+0100
@@ -1,6 +1,5 @@
+black
flake8
-pep8-naming
pytest>=3
pytest-cov
-pytest-pep8
sphinx
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonlines-1.2.0/requirements.txt
new/jsonlines-2.0.0/requirements.txt
--- old/jsonlines-1.2.0/requirements.txt 2017-08-17 12:08:20.000000000
+0200
+++ new/jsonlines-2.0.0/requirements.txt 1970-01-01 01:00:00.000000000
+0100
@@ -1 +0,0 @@
-six
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonlines-1.2.0/setup.cfg
new/jsonlines-2.0.0/setup.cfg
--- old/jsonlines-1.2.0/setup.cfg 2017-08-17 12:08:20.000000000 +0200
+++ new/jsonlines-2.0.0/setup.cfg 2021-01-04 17:03:18.000000000 +0100
@@ -1,9 +1,34 @@
-[bdist_wheel]
-universal = 1
-
[metadata]
+name = jsonlines
+version = 2.0.0
+author = Wouter Bolsterlee
+author_email = [email protected]
+license = BSD
license_file = LICENSE.rst
+description = Library with helpers for the jsonlines file format
+long_description = file: README.rst
+url = https://github.com/wbolster/jsonlines
+classifiers =
+ Development Status :: 5 - Production/Stable
+ Intended Audience :: Developers
+ Intended Audience :: System Administrators
+ License :: OSI Approved :: BSD License
+ Programming Language :: Python
+ Programming Language :: Python :: 3
+ Programming Language :: Python :: 3 :: Only
+ Topic :: Internet :: Log Analysis
+ Topic :: Software Development :: Libraries :: Python Modules
+ Topic :: System :: Logging
+ Topic :: Utilities
+
+[options]
+packages = jsonlines
+python_requires = >=3.6
[build_sphinx]
source-dir = doc/
build-dir = doc/build/
+
+[flake8]
+max-line-length = 88
+extend-ignore = E203
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonlines-1.2.0/setup.py new/jsonlines-2.0.0/setup.py
--- old/jsonlines-1.2.0/setup.py 2017-08-17 12:08:20.000000000 +0200
+++ new/jsonlines-2.0.0/setup.py 2021-01-04 17:03:18.000000000 +0100
@@ -1,32 +1,3 @@
-import os
from setuptools import setup
-
-with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as fp:
- long_description = fp.read()
-
-setup(
- name="jsonlines",
- version="1.2.0",
- description="Library with helpers for the jsonlines file format",
- long_description=long_description,
- author="Wouter Bolsterlee",
- author_email="[email protected]",
- url="https://github.com/wbolster/jsonlines",
- packages=['jsonlines'],
- install_requires=['six'],
- license='BSD',
- classifiers=[
- 'Development Status :: 5 - Production/Stable',
- 'Intended Audience :: Developers',
- 'Intended Audience :: System Administrators',
- 'License :: OSI Approved :: BSD License',
- 'Programming Language :: Python',
- 'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 3',
- 'Topic :: Internet :: Log Analysis',
- 'Topic :: Software Development :: Libraries :: Python Modules',
- 'Topic :: System :: Logging',
- 'Topic :: Utilities',
- ],
-)
+setup()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonlines-1.2.0/tests/test_jsonlines.py
new/jsonlines-2.0.0/tests/test_jsonlines.py
--- old/jsonlines-1.2.0/tests/test_jsonlines.py 2017-08-17 12:08:20.000000000
+0200
+++ new/jsonlines-2.0.0/tests/test_jsonlines.py 2021-01-04 17:03:18.000000000
+0100
@@ -11,15 +11,15 @@
SAMPLE_BYTES = b'{"a": 1}\n{"b": 2}\n'
-SAMPLE_TEXT = SAMPLE_BYTES.decode('utf-8')
+SAMPLE_TEXT = SAMPLE_BYTES.decode("utf-8")
def test_reader():
fp = io.BytesIO(SAMPLE_BYTES)
with jsonlines.Reader(fp) as reader:
it = iter(reader)
- assert next(it) == {'a': 1}
- assert next(it) == {'b': 2}
+ assert next(it) == {"a": 1}
+ assert next(it) == {"b": 2}
with pytest.raises(StopIteration):
next(it)
with pytest.raises(EOFError):
@@ -27,26 +27,28 @@
def test_reading_from_iterable():
- with jsonlines.Reader(['1', b'{}']) as reader:
+ with jsonlines.Reader(["1", b"{}"]) as reader:
assert list(reader) == [1, {}]
- assert 'wrapping <list at ' in repr(reader)
+ assert "wrapping <list at " in repr(reader)
def test_writer_text():
fp = io.StringIO()
with jsonlines.Writer(fp) as writer:
- writer.write({'a': 1})
- writer.write({'b': 2})
+ writer.write({"a": 1})
+ writer.write({"b": 2})
assert fp.getvalue() == SAMPLE_TEXT
def test_writer_binary():
fp = io.BytesIO()
with jsonlines.Writer(fp) as writer:
- writer.write_all([
- {'a': 1},
- {'b': 2},
- ])
+ writer.write_all(
+ [
+ {"a": 1},
+ {"b": 2},
+ ]
+ )
assert fp.getvalue() == SAMPLE_BYTES
@@ -63,7 +65,7 @@
def test_invalid_lines():
- data = u'[1, 2'
+ data = "[1, 2"
with jsonlines.Reader(io.StringIO(data)) as reader:
with pytest.raises(jsonlines.InvalidLineError) as excinfo:
reader.read()
@@ -73,7 +75,7 @@
def test_skip_invalid():
- fp = io.StringIO(u"12\ninvalid\n34")
+ fp = io.StringIO("12\ninvalid\n34")
reader = jsonlines.Reader(fp)
it = reader.iter(skip_invalid=True)
assert next(it) == 12
@@ -81,7 +83,7 @@
def test_empty_strings_in_iterable():
- input = ['123', '', '456']
+ input = ["123", "", "456"]
it = iter(jsonlines.Reader(input))
assert next(it) == 123
with pytest.raises(jsonlines.InvalidLineError):
@@ -93,10 +95,10 @@
def test_invalid_utf8():
- with jsonlines.Reader([b'\xff\xff']) as reader:
+ with jsonlines.Reader([b"\xff\xff"]) as reader:
with pytest.raises(jsonlines.InvalidLineError) as excinfo:
reader.read()
- assert 'line is not valid utf-8' in str(excinfo.value)
+ assert "line is not valid utf-8" in str(excinfo.value)
def test_empty_lines():
@@ -113,7 +115,7 @@
def test_typed_reads():
- with jsonlines.Reader(io.StringIO(u'12\n"foo"\n')) as reader:
+ with jsonlines.Reader(io.StringIO('12\n"foo"\n')) as reader:
assert reader.read(type=int) == 12
with pytest.raises(jsonlines.InvalidLineError) as excinfo:
reader.read(type=float)
@@ -123,12 +125,12 @@
def test_typed_iteration():
- fp = io.StringIO(u'1\n2\n')
+ fp = io.StringIO("1\n2\n")
with jsonlines.Reader(fp) as reader:
actual = list(reader.iter(type=int))
assert actual == [1, 2]
- fp = io.StringIO(u'1\n2\n')
+ fp = io.StringIO("1\n2\n")
with jsonlines.Reader(fp) as reader:
it = reader.iter(type=str)
with pytest.raises(jsonlines.InvalidLineError) as excinfo:
@@ -140,25 +142,29 @@
def test_writer_flags():
fp = io.BytesIO()
with jsonlines.Writer(fp, compact=True, sort_keys=True) as writer:
- writer.write(collections.OrderedDict([
- ('b', 2),
- ('a', 1),
- ]))
+ writer.write(
+ collections.OrderedDict(
+ [
+ ("b", 2),
+ ("a", 1),
+ ]
+ )
+ )
assert fp.getvalue() == b'{"a":1,"b":2}\n'
def test_custom_dumps():
fp = io.BytesIO()
- writer = jsonlines.Writer(fp, dumps=lambda obj: 'oh hai')
+ writer = jsonlines.Writer(fp, dumps=lambda obj: "oh hai")
with writer:
writer.write({})
- assert fp.getvalue() == b'oh hai\n'
+ assert fp.getvalue() == b"oh hai\n"
def test_custom_loads():
fp = io.BytesIO(b"{}\n")
- with jsonlines.Reader(fp, loads=lambda s: 'uh what') as reader:
- assert reader.read() == 'uh what'
+ with jsonlines.Reader(fp, loads=lambda s: "uh what") as reader:
+ assert reader.read() == "uh what"
def test_open_reading():
@@ -171,7 +177,7 @@
def test_open_writing():
with tempfile.NamedTemporaryFile("w+b") as fp:
- with jsonlines.open(fp.name, mode='w') as writer:
+ with jsonlines.open(fp.name, mode="w") as writer:
writer.write(123)
assert fp.read() == b"123\n"
assert fp.name in repr(writer)
@@ -179,14 +185,14 @@
def test_open_and_append_writing():
with tempfile.NamedTemporaryFile("w+b") as fp:
- with jsonlines.open(fp.name, mode='w') as writer:
+ with jsonlines.open(fp.name, mode="w") as writer:
writer.write(123)
- with jsonlines.open(fp.name, mode='a') as writer:
+ with jsonlines.open(fp.name, mode="a") as writer:
writer.write(456)
assert fp.read() == b"123\n456\n"
def test_open_invalid_mode():
with pytest.raises(ValueError) as excinfo:
- jsonlines.open('foo', mode='foo')
- assert 'mode' in str(excinfo.value)
+ jsonlines.open("foo", mode="foo")
+ assert "mode" in str(excinfo.value)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonlines-1.2.0/tox.ini new/jsonlines-2.0.0/tox.ini
--- old/jsonlines-1.2.0/tox.ini 2017-08-17 12:08:20.000000000 +0200
+++ new/jsonlines-2.0.0/tox.ini 2021-01-04 17:03:18.000000000 +0100
@@ -1,10 +1,13 @@
[tox]
-envlist = py27,py33,py34,py35,py36,flake8
+envlist = py36,py37,py38,py39,flake8
[testenv]
deps = -rrequirements-dev.txt
-commands = py.test {posargs} tests/
+commands = pytest {posargs} tests/
-[testenv:flake8]
+[testenv:linters]
+basepython = python3.9
deps = -rrequirements-dev.txt
-commands = flake8 jsonlines/ tests/
+commands =
+ flake8 jsonlines/ tests/
+ black --check jsonlines/ tests/