Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-sortedcollections for
openSUSE:Factory checked in at 2021-01-31 16:52:04
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-sortedcollections (Old)
and /work/SRC/openSUSE:Factory/.python-sortedcollections.new.28504 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-sortedcollections"
Sun Jan 31 16:52:04 2021 rev:6 rq:867972 version:2.1.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-sortedcollections/python-sortedcollections.changes
2020-07-24 10:04:07.509864287 +0200
+++
/work/SRC/openSUSE:Factory/.python-sortedcollections.new.28504/python-sortedcollections.changes
2021-01-31 16:52:05.908710155 +0100
@@ -1,0 +2,24 @@
+Sat Jan 30 05:20:31 UTC 2021 - John Vandenberg <[email protected]>
+
+- Update to v2.1.0
+ * Add NearestDict
+ * Update for Python 3
+ * Fixes for doctest support
+ * Add NearestDict implementation
+ * Update docs to reference NearestDict
+ * Use Python3 defaults for inheritance
+ * Use f-strings
+- from v2.0.0
+ * Remove shims for Python 2
+ * Add support for mypy
+ * Drop need for "gj" from requirements
+ * Load version from __init__.py rather than by import
+ * Add __all__ to __init__.py for flake8
+ * Small fixes/changes for linters/formatters/type-checkers
+- from v1.2.3
+ * Add support for "blue" formatter
+ * Fixes for doctest support
+- from v1.2.2
+ * Add pickle support for IndexableSet
+
+-------------------------------------------------------------------
Old:
----
v1.2.1.tar.gz
New:
----
v2.1.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-sortedcollections.spec ++++++
--- /var/tmp/diff_new_pack.9CoKD7/_old 2021-01-31 16:52:06.628711195 +0100
+++ /var/tmp/diff_new_pack.9CoKD7/_new 2021-01-31 16:52:06.628711195 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-sortedcollections
#
-# Copyright (c) 2020 SUSE LLC
+# 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
@@ -17,8 +17,9 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
+%define skip_python2 1
Name: python-sortedcollections
-Version: 1.2.1
+Version: 2.1.0
Release: 0
Summary: Python Sorted Collections
License: Apache-2.0
@@ -53,7 +54,7 @@
%prep
%setup -q -n python-sortedcollections-%{version}
-%autopatch -p1
+rm tox.ini
%build
%python_build
++++++ v1.2.1.tar.gz -> v2.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-sortedcollections-1.2.1/.github/workflows/integration.yml
new/python-sortedcollections-2.1.0/.github/workflows/integration.yml
--- old/python-sortedcollections-1.2.1/.github/workflows/integration.yml
1970-01-01 01:00:00.000000000 +0100
+++ new/python-sortedcollections-2.1.0/.github/workflows/integration.yml
2021-01-18 23:01:45.000000000 +0100
@@ -0,0 +1,52 @@
+name: integration
+
+on: [push]
+
+jobs:
+
+ checks:
+ runs-on: ubuntu-latest
+ strategy:
+ max-parallel: 8
+ matrix:
+ check: [bluecheck, doc8, docs, flake8, isortcheck, mypy, pylint,
rstcheck]
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.9
+ - name: Install dependencies
+ run: |
+ pip install --upgrade pip
+ pip install tox
+ - name: Run checks with tox
+ run: |
+ tox -e ${{ matrix.check }}
+
+ tests:
+ needs: checks
+ runs-on: ${{ matrix.os }}
+ strategy:
+ max-parallel: 8
+ matrix:
+ os: [ubuntu-latest, macos-latest, windows-latest, ubuntu-16.04]
+ python-version: [3.6, 3.7, 3.8, 3.9]
+
+ steps:
+ - name: Set up Python ${{ matrix.python-version }} x64
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+ architecture: x64
+
+ - uses: actions/checkout@v2
+
+ - name: Install tox
+ run: |
+ pip install --upgrade pip
+ pip install tox
+
+ - name: Test with tox
+ run: tox -e py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-sortedcollections-1.2.1/.github/workflows/release.yml
new/python-sortedcollections-2.1.0/.github/workflows/release.yml
--- old/python-sortedcollections-1.2.1/.github/workflows/release.yml
1970-01-01 01:00:00.000000000 +0100
+++ new/python-sortedcollections-2.1.0/.github/workflows/release.yml
2021-01-18 23:01:45.000000000 +0100
@@ -0,0 +1,38 @@
+name: release
+
+on:
+ push:
+ tags:
+ - v*
+
+jobs:
+
+ upload:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.9
+
+ - name: Install dependencies
+ run: |
+ pip install --upgrade pip
+ pip install -r requirements.txt
+
+ - name: Create source dist
+ run: python setup.py sdist
+
+ - name: Create wheel dist
+ run: python setup.py bdist_wheel
+
+ - name: Upload with twine
+ env:
+ TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
+ TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
+ run: |
+ ls -l dist/*
+ twine upload dist/*
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/.gitignore
new/python-sortedcollections-2.1.0/.gitignore
--- old/python-sortedcollections-1.2.1/.gitignore 2020-06-07
21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/.gitignore 2021-01-18
23:01:45.000000000 +0100
@@ -12,5 +12,6 @@
/build/
/dist/
/sortedcollections.egg-info/
+/docs/_build/
.DS_Store
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/.pylintrc
new/python-sortedcollections-2.1.0/.pylintrc
--- old/python-sortedcollections-1.2.1/.pylintrc 2020-06-07
21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/.pylintrc 2021-01-18
23:01:45.000000000 +0100
@@ -138,7 +138,9 @@
xreadlines-attribute,
deprecated-sys-function,
exception-escape,
- comprehension-escape
+ comprehension-escape,
+ super-with-arguments,
+ raise-missing-from
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/.travis.yml
new/python-sortedcollections-2.1.0/.travis.yml
--- old/python-sortedcollections-1.2.1/.travis.yml 2020-06-07
21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/.travis.yml 1970-01-01
01:00:00.000000000 +0100
@@ -1,24 +0,0 @@
-sudo: false
-language: python
-install: pip install tox
-script: tox
-matrix:
- include:
- - python: 2.7
- env: TOXENV=py27
- - python: 3.4
- env: TOXENV=py34
- - python: 3.5
- env: TOXENV=py35
- - python: 3.6
- env: TOXENV=py36
- - python: 3.7
- dist: xenial
- env: TOXENV=py37
- - python: pypy
- env: TOXENV=pypy
- - python: pypy3
- env: TOXENV=pypy3
- - python: 3.7
- dist: xenial
- env: TOXENV=lint
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/LICENSE
new/python-sortedcollections-2.1.0/LICENSE
--- old/python-sortedcollections-1.2.1/LICENSE 2020-06-07 21:53:14.000000000
+0200
+++ new/python-sortedcollections-2.1.0/LICENSE 2021-01-18 23:01:45.000000000
+0100
@@ -1,4 +1,4 @@
-Copyright 2015-2019 Grant Jenks
+Copyright 2015-2021 Grant Jenks
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/README.rst
new/python-sortedcollections-2.1.0/README.rst
--- old/python-sortedcollections-1.2.1/README.rst 2020-06-07
21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/README.rst 2021-01-18
23:01:45.000000000 +0100
@@ -11,20 +11,21 @@
<http://www.grantjenks.com/docs/sortedcontainers/>`_ module.
- ValueSortedDict - Dictionary with (key, value) item pairs sorted by value.
- ItemSortedDict - Dictionary with key-function support for item pairs.
+- NearestDict - Dictionary with nearest-key lookup.
- OrderedDict - Ordered dictionary with numeric indexing support.
- OrderedSet - Ordered set with numeric indexing support.
- IndexableDict - Dictionary with numeric indexing support.
- IndexableSet - Set with numeric indexing support.
- SegmentList - List with fast random access insertion and deletion.
- 100% code coverage testing.
-- Developed on Python 3.7
-- Tested on CPython 2.7, 3.4, 3.5, 3.6, 3.7 and PyPy, PyPy3
+- Developed on Python 3.9
+- Tested on CPython 3.6, 3.7, 3.8, and 3.9
-.. image::
https://api.travis-ci.org/grantjenks/python-sortedcollections.svg?branch=master
- :target: http://www.grantjenks.com/docs/sortedcollections/
+.. image::
https://github.com/grantjenks/python-sortedcollections/workflows/integration/badge.svg
+ :target:
https://github.com/grantjenks/python-sortedcollections/actions?query=workflow%3Aintegration
-.. image::
https://ci.appveyor.com/api/projects/status/github/grantjenks/python-sortedcollections?branch=master&svg=true
- :target: http://www.grantjenks.com/docs/sortedcollections/
+.. image::
https://github.com/grantjenks/python-sortedcollections/workflows/release/badge.svg
+ :target:
https://github.com/grantjenks/python-sortedcollections/actions?query=workflow%3Arelease
Quickstart
----------
@@ -40,7 +41,7 @@
.. code-block:: python
>>> from sortedcollections import ValueSortedDict
- >>> help(ValueSortedDict)
+ >>> help(ValueSortedDict) # doctest: +SKIP
.. _`Sorted Collections`: http://www.grantjenks.com/docs/sortedcollections/
@@ -49,6 +50,7 @@
- `Value Sorted Dictionary Recipe`_
- `Item Sorted Dictionary Recipe`_
+- `Nearest Dictionary Recipe`_
- `Ordered Dictionary Recipe`_
- `Ordered Set Recipe`_
- `Indexable Dictionary Recipe`_
@@ -57,6 +59,7 @@
.. _`Value Sorted Dictionary Recipe`:
http://www.grantjenks.com/docs/sortedcollections/valuesorteddict.html
.. _`Item Sorted Dictionary Recipe`:
http://www.grantjenks.com/docs/sortedcollections/itemsorteddict.html
+.. _`Nearest Dictionary Recipe`:
http://www.grantjenks.com/docs/sortedcollections/nearestdict.html
.. _`Ordered Dictionary Recipe`:
http://www.grantjenks.com/docs/sortedcollections/ordereddict.html
.. _`Ordered Set Recipe`:
http://www.grantjenks.com/docs/sortedcollections/orderedset.html
.. _`Indexable Dictionary Recipe`:
http://www.grantjenks.com/docs/sortedcollections/indexabledict.html
@@ -79,7 +82,7 @@
Sorted Collections License
--------------------------
-Copyright 2015-2019 Grant Jenks
+Copyright 2015-2021 Grant Jenks
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/appveyor.yml
new/python-sortedcollections-2.1.0/appveyor.yml
--- old/python-sortedcollections-1.2.1/appveyor.yml 2020-06-07
21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/appveyor.yml 1970-01-01
01:00:00.000000000 +0100
@@ -1,22 +0,0 @@
-environment:
-
- matrix:
-
- - PYTHON: "C:\\Python27"
- - PYTHON: "C:\\Python35"
- - PYTHON: "C:\\Python36"
- - PYTHON: "C:\\Python37"
- - PYTHON: "C:\\Python27-x64"
- - PYTHON: "C:\\Python35-x64"
- - PYTHON: "C:\\Python36-x64"
- - PYTHON: "C:\\Python37-x64"
-
-install:
-
- - "%PYTHON%\\python.exe -m pip install tox"
-
-build: off
-
-test_script:
-
- - "%PYTHON%\\python.exe -m tox -e py"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/docs/conf.py
new/python-sortedcollections-2.1.0/docs/conf.py
--- old/python-sortedcollections-1.2.1/docs/conf.py 2020-06-07
21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/docs/conf.py 2021-01-18
23:01:45.000000000 +0100
@@ -21,8 +21,8 @@
# -- Project information -----------------------------------------------------
project = 'Sorted Collections'
-copyright = sortedcollections.__copyright__
-author = sortedcollections.__author__
+copyright = 'Apache 2.0'
+author = 'Grant Jenks'
# The short X.Y version
version = sortedcollections.__version__
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/docs/index.rst
new/python-sortedcollections-2.1.0/docs/index.rst
--- old/python-sortedcollections-1.2.1/docs/index.rst 2020-06-07
21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/docs/index.rst 2021-01-18
23:01:45.000000000 +0100
@@ -5,6 +5,7 @@
valuesorteddict
itemsorteddict
+ nearestdict
ordereddict
orderedset
indexabledict
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/docs/nearestdict.rst
new/python-sortedcollections-2.1.0/docs/nearestdict.rst
--- old/python-sortedcollections-1.2.1/docs/nearestdict.rst 1970-01-01
01:00:00.000000000 +0100
+++ new/python-sortedcollections-2.1.0/docs/nearestdict.rst 2021-01-18
23:01:45.000000000 +0100
@@ -0,0 +1,6 @@
+Nearest Dictionary Recipe
+=========================
+
+.. autoclass:: sortedcollections.NearestDict
+ :special-members:
+ :members:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/mypy.ini
new/python-sortedcollections-2.1.0/mypy.ini
--- old/python-sortedcollections-1.2.1/mypy.ini 1970-01-01 01:00:00.000000000
+0100
+++ new/python-sortedcollections-2.1.0/mypy.ini 2021-01-18 23:01:45.000000000
+0100
@@ -0,0 +1,4 @@
+[mypy]
+
+[mypy-sortedcontainers.*]
+ignore_missing_imports = True
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/requirements.txt
new/python-sortedcollections-2.1.0/requirements.txt
--- old/python-sortedcollections-1.2.1/requirements.txt 2020-06-07
21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/requirements.txt 2021-01-18
23:01:45.000000000 +0100
@@ -1,11 +1,12 @@
+-e .
+blue
coverage
doc8
-gj
+mypy
pylint
pytest
pytest-cov
rstcheck
-sortedcontainers
sphinx
tox
twine
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/setup.py
new/python-sortedcollections-2.1.0/setup.py
--- old/python-sortedcollections-1.2.1/setup.py 2020-06-07 21:53:14.000000000
+0200
+++ new/python-sortedcollections-2.1.0/setup.py 2021-01-18 23:01:45.000000000
+0100
@@ -1,3 +1,6 @@
+import pathlib
+import re
+
from setuptools import setup
from setuptools.command.test import test as TestCommand
@@ -7,8 +10,10 @@
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
+
def run_tests(self):
import tox
+
errno = tox.cmdline(self.test_args)
exit(errno)
@@ -16,9 +21,13 @@
with open('README.rst') as reader:
readme = reader.read()
+init_text = (pathlib.Path('sortedcollections') / '__init__.py').read_text()
+match = re.search(r"^__version__ = '(.+)'$", init_text, re.MULTILINE)
+version = match.group(1)
+
setup(
name='sortedcollections',
- version='1.2.1',
+ version=version,
description='Python Sorted Collections',
long_description=readme,
author='Grant Jenks',
@@ -35,15 +44,10 @@
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Programming Language :: Python',
- 'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.2',
- 'Programming Language :: Python :: 3.3',
- 'Programming Language :: Python :: 3.4',
- 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
+ 'Programming Language :: Python :: 3.8',
+ 'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-sortedcollections-1.2.1/sortedcollections/__init__.py
new/python-sortedcollections-2.1.0/sortedcollections/__init__.py
--- old/python-sortedcollections-1.2.1/sortedcollections/__init__.py
2020-06-07 21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/sortedcollections/__init__.py
2021-01-18 23:01:45.000000000 +0100
@@ -2,23 +2,47 @@
SortedCollections is an Apache2 licensed Python sorted collections library.
-:copyright: (c) 2015-2018 by Grant Jenks.
+>>> from sortedcollections import ValueSortedDict
+>>> vsd = ValueSortedDict({'a': 2, 'b': 1, 'c': 3})
+>>> list(vsd.keys())
+['b', 'a', 'c']
+
+:copyright: (c) 2015-2021 by Grant Jenks.
:license: Apache 2.0, see LICENSE for more details.
"""
from sortedcontainers import (
- SortedList, SortedListWithKey, SortedDict, SortedSet
+ SortedDict,
+ SortedList,
+ SortedListWithKey,
+ SortedSet,
)
-from .recipes import IndexableDict, IndexableSet
-from .recipes import ItemSortedDict, ValueSortedDict
-from .recipes import OrderedSet, SegmentList
+from .nearestdict import NearestDict
from .ordereddict import OrderedDict
+from .recipes import (
+ IndexableDict,
+ IndexableSet,
+ ItemSortedDict,
+ OrderedSet,
+ SegmentList,
+ ValueSortedDict,
+)
+
+__all__ = [
+ 'IndexableDict',
+ 'IndexableSet',
+ 'ItemSortedDict',
+ 'NearestDict',
+ 'OrderedDict',
+ 'OrderedSet',
+ 'SegmentList',
+ 'SortedDict',
+ 'SortedList',
+ 'SortedListWithKey',
+ 'SortedSet',
+ 'ValueSortedDict',
+]
-__title__ = 'sortedcollections'
-__version__ = '1.2.1'
-__build__ = 0x010201
-__author__ = 'Grant Jenks'
-__license__ = 'Apache 2.0'
-__copyright__ = 'Copyright 2015-2018 Grant Jenks'
+__version__ = '2.1.0'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-sortedcollections-1.2.1/sortedcollections/nearestdict.py
new/python-sortedcollections-2.1.0/sortedcollections/nearestdict.py
--- old/python-sortedcollections-1.2.1/sortedcollections/nearestdict.py
1970-01-01 01:00:00.000000000 +0100
+++ new/python-sortedcollections-2.1.0/sortedcollections/nearestdict.py
2021-01-18 23:01:45.000000000 +0100
@@ -0,0 +1,123 @@
+"""NearestDict implementation.
+
+One primary use case for this data structure is storing data by a
+`datetime.datetime` or `float` key.
+"""
+
+from sortedcontainers import SortedDict
+
+
+class NearestDict(SortedDict):
+ """A dict using nearest-key lookup.
+
+ A :class:`SortedDict` subclass that uses nearest-key lookup instead of
+ exact-key lookup. Optionally, you can specify a rounding mode to return the
+ nearest key less than or equal to or greater than or equal to the provided
+ key.
+
+ When using :attr:`NearestDict.NEAREST` the keys must support subtraction to
+ allow finding the nearest key (by find the key with the smallest difference
+ to the given one).
+
+ Additional methods:
+
+ * :meth:`NearestDict.nearest_key`
+
+ Example usage:
+
+ >>> d = NearestDict({1.0: 'foo'})
+ >>> d[1.0]
+ 'foo'
+ >>> d[0.0]
+ 'foo'
+ >>> d[2.0]
+ 'foo'
+ """
+
+ NEAREST_PREV = -1
+ NEAREST = 0
+ NEAREST_NEXT = 1
+
+ def __init__(self, *args, **kwargs):
+ """Initialize a NearestDict instance.
+
+ Optional `rounding` argument dictates how
+ :meth:`NearestDict.nearest_key` rounds. It must be one of
+ :attr:`NearestDict.NEAREST_NEXT`, :attr:`NearestDict.NEAREST`, or
+ :attr:`NearestDict.NEAREST_PREV`. (Default:
+ :attr:`NearestDict.NEAREST`)
+
+ :params rounding: how to round on nearest-key lookup (optional)
+ :params args: positional arguments for :class:`SortedDict`.
+ :params kwargs: keyword arguments for :class:`SortedDict`.
+ """
+ self.rounding = kwargs.pop('rounding', self.NEAREST)
+ super().__init__(*args, **kwargs)
+
+ def nearest_key(self, request):
+ """Return nearest-key to `request`, respecting `self.rounding`.
+
+ >>> d = NearestDict({1.0: 'foo'})
+ >>> d.nearest_key(0.0)
+ 1.0
+ >>> d.nearest_key(2.0)
+ 1.0
+
+ >>> d = NearestDict({1.0: 'foo'}, rounding=NearestDict.NEAREST_PREV)
+ >>> d.nearest_key(0.0)
+ Traceback (most recent call last):
+ ...
+ KeyError: 'No key below 0.0 found'
+ >>> d.nearest_key(2.0)
+ 1.0
+
+ :param request: nearest-key lookup value
+ :return: key nearest to `request`, respecting `rounding`
+ :raises KeyError: if no appropriate key can be found
+ """
+ key_list = self.keys()
+
+ if not key_list:
+ raise KeyError('NearestDict is empty')
+
+ index = self.bisect_left(request)
+
+ if index >= len(key_list):
+ if self.rounding == self.NEAREST_NEXT:
+ raise KeyError(f'No key above {request!r} found')
+ return key_list[index - 1]
+ if key_list[index] == request:
+ return key_list[index]
+ if index == 0 and self.rounding == self.NEAREST_PREV:
+ raise KeyError(f'No key below {request!r} found')
+ if self.rounding == self.NEAREST_PREV:
+ return key_list[index - 1]
+ if self.rounding == self.NEAREST_NEXT:
+ return key_list[index]
+ if abs(key_list[index - 1] - request) < abs(key_list[index] - request):
+ return key_list[index - 1]
+ return key_list[index]
+
+ def __getitem__(self, request):
+ """Return item corresponding to :meth:`.nearest_key`.
+
+ :param request: nearest-key lookup value
+ :return: item corresponding to key nearest `request`
+ :raises KeyError: if no appropriate item can be found
+
+ >>> d = NearestDict({1.0: 'foo'})
+ >>> d[0.0]
+ 'foo'
+ >>> d[2.0]
+ 'foo'
+
+ >>> d = NearestDict({1.0: 'foo'}, rounding=NearestDict.NEAREST_NEXT)
+ >>> d[0.0]
+ 'foo'
+ >>> d[2.0]
+ Traceback (most recent call last):
+ ...
+ KeyError: 'No key above 2.0 found'
+ """
+ key = self.nearest_key(request)
+ return super().__getitem__(key)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-sortedcollections-1.2.1/sortedcollections/ordereddict.py
new/python-sortedcollections-2.1.0/sortedcollections/ordereddict.py
--- old/python-sortedcollections-1.2.1/sortedcollections/ordereddict.py
2020-06-07 21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/sortedcollections/ordereddict.py
2021-01-18 23:01:45.000000000 +0100
@@ -10,25 +10,12 @@
from .recipes import abc
-###############################################################################
-# BEGIN Python 2/3 Shims
-###############################################################################
-
-from sys import hexversion # pylint: disable=wrong-import-order
-
-if hexversion < 0x03000000:
- from itertools import imap as map # pylint:
disable=no-name-in-module,redefined-builtin,ungrouped-imports
-
-###############################################################################
-# END Python 2/3 Shims
-###############################################################################
-
NONE = object()
class KeysView(abc.KeysView, abc.Sequence):
"Read-only view of mapping keys."
- # pylint:
disable=too-few-public-methods,protected-access,too-many-ancestors
+ # noqa pylint:
disable=too-few-public-methods,protected-access,too-many-ancestors
def __getitem__(self, index):
"``keys_view[index]``"
_nums = self._mapping._nums
@@ -40,7 +27,7 @@
class ItemsView(abc.ItemsView, abc.Sequence):
"Read-only view of mapping items."
- # pylint:
disable=too-few-public-methods,protected-access,too-many-ancestors
+ # noqa pylint:
disable=too-few-public-methods,protected-access,too-many-ancestors
def __getitem__(self, index):
"``items_view[index]``"
_mapping = self._mapping
@@ -56,7 +43,7 @@
class ValuesView(abc.ValuesView, abc.Sequence):
"Read-only view of mapping values."
- # pylint:
disable=too-few-public-methods,protected-access,too-many-ancestors
+ # noqa pylint:
disable=too-few-public-methods,protected-access,too-many-ancestors
def __getitem__(self, index):
"``items_view[index]``"
_mapping = self._mapping
@@ -85,6 +72,7 @@
The dict views support the sequence abstract base class.
"""
+
# pylint: disable=super-init-not-called
def __init__(self, *args, **kwargs):
self._keys = {}
@@ -178,7 +166,7 @@
@recursive_repr()
def __repr__(self):
"Text representation of mapping."
- return '%s(%r)' % (self.__class__.__name__, list(self.items()))
+ return f'{self.__class__.__name__}({list(self.items())!r})'
__str__ = __repr__
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-sortedcollections-1.2.1/sortedcollections/recipes.py
new/python-sortedcollections-2.1.0/sortedcollections/recipes.py
--- old/python-sortedcollections-1.2.1/sortedcollections/recipes.py
2020-06-07 21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/sortedcollections/recipes.py
2021-01-18 23:01:45.000000000 +0100
@@ -2,23 +2,12 @@
"""
+from collections import abc
from copy import deepcopy
from itertools import count
-from sortedcontainers import SortedKeyList, SortedDict, SortedSet
-from sortedcontainers.sortedlist import recursive_repr
-###############################################################################
-# BEGIN Python 2/3 Shims
-###############################################################################
-
-try:
- from collections import abc
-except ImportError:
- import collections as abc
-
-###############################################################################
-# END Python 2/3 Shims
-###############################################################################
+from sortedcontainers import SortedDict, SortedKeyList, SortedSet
+from sortedcontainers.sortedlist import recursive_repr
class IndexableDict(SortedDict):
@@ -34,8 +23,9 @@
The dict views support the sequence abstract base class.
"""
+
def __init__(self, *args, **kwargs):
- super(IndexableDict, self).__init__(hash, *args, **kwargs)
+ super().__init__(hash, *args, **kwargs)
class IndexableSet(SortedSet):
@@ -50,9 +40,13 @@
`IndexableSet` implements the sequence abstract base class.
"""
+
# pylint: disable=too-many-ancestors
def __init__(self, *args, **kwargs):
- super(IndexableSet, self).__init__(*args, key=hash, **kwargs)
+ super().__init__(*args, key=hash, **kwargs)
+
+ def __reduce__(self):
+ return self.__class__, (set(self),)
class ItemSortedDict(SortedDict):
@@ -71,15 +65,18 @@
the callable given as the first argument.
"""
+
def __init__(self, *args, **kwargs):
assert args and callable(args[0])
args = list(args)
func = self._func = args[0]
+
def key_func(key):
"Apply key function to (key, value) item pair."
return func(key, self[key])
+
args[0] = key_func
- super(ItemSortedDict, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
def __delitem__(self, key):
"``del mapping[key]``"
@@ -134,24 +131,29 @@
``sorted`` function.
"""
+
def __init__(self, *args, **kwargs):
args = list(args)
if args and callable(args[0]):
func = self._func = args[0]
+
def key_func(key):
"Apply key function to ``mapping[value]``."
return func(self[key])
+
args[0] = key_func
else:
self._func = None
+
def key_func(key):
"Return mapping value for key."
return self[key]
+
if args and args[0] is None:
args[0] = key_func
else:
args.insert(0, key_func)
- super(ValueSortedDict, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
def __delitem__(self, key):
"``del mapping[key]``"
@@ -183,14 +185,8 @@
@recursive_repr()
def __repr__(self):
- temp = '{0}({1}, {{{2}}})'
- items = ', '.join('{0}: {1}'.format(repr(key), repr(self[key]))
- for key in self._list)
- return temp.format(
- self.__class__.__name__,
- repr(self._func),
- items
- )
+ items = ', '.join(f'{key!r}: {self[key]!r}' for key in self._list)
+ return f'{self.__class__.__name__}({self._func!r}, {{{items}}})'
class OrderedSet(abc.MutableSet, abc.Sequence):
@@ -208,6 +204,7 @@
OrderedSet also implements the collections.Sequence interface.
"""
+
# pylint: disable=too-many-ancestors
def __init__(self, iterable=()):
# pylint: disable=super-init-not-called
@@ -248,7 +245,7 @@
try:
return self._keys[value]
except KeyError:
- raise ValueError('%r is not in %s' % (value, type(self).__name__))
+ raise ValueError(f'{value!r} is not in {type(self).__name__}')
def add(self, value):
"Add element, value, to set."
@@ -265,7 +262,7 @@
def __repr__(self):
"Text representation of set."
- return '%s(%r)' % (type(self).__name__, list(self))
+ return f'{type(self).__name__}({list(self)!r})'
__str__ = __repr__
@@ -278,9 +275,10 @@
implemented for SegmentList.
"""
+
# pylint: disable=too-many-ancestors
def __init__(self, iterable=()):
- super(SegmentList, self).__init__(iterable, self.zero)
+ super().__init__(iterable, self.zero)
@staticmethod
def zero(_):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/tests/test_doctest.py
new/python-sortedcollections-2.1.0/tests/test_doctest.py
--- old/python-sortedcollections-1.2.1/tests/test_doctest.py 1970-01-01
01:00:00.000000000 +0100
+++ new/python-sortedcollections-2.1.0/tests/test_doctest.py 2021-01-18
23:01:45.000000000 +0100
@@ -0,0 +1,23 @@
+import doctest
+
+import sortedcollections
+import sortedcollections.ordereddict
+import sortedcollections.recipes
+
+
+def test_sortedcollections():
+ failed, attempted = doctest.testmod(sortedcollections)
+ assert attempted > 0
+ assert failed == 0
+
+
+def test_sortedcollections_ordereddict():
+ failed, attempted = doctest.testmod(sortedcollections.ordereddict)
+ assert attempted > 0
+ assert failed == 0
+
+
+def test_sortedcollections_recipes():
+ failed, attempted = doctest.testmod(sortedcollections.recipes)
+ assert attempted > 0
+ assert failed == 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-sortedcollections-1.2.1/tests/test_itemsorteddict.py
new/python-sortedcollections-2.1.0/tests/test_itemsorteddict.py
--- old/python-sortedcollections-1.2.1/tests/test_itemsorteddict.py
2020-06-07 21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/tests/test_itemsorteddict.py
2021-01-18 23:01:45.000000000 +0100
@@ -1,21 +1,28 @@
"Test sortedcollections.ItemSortedDict"
import copy
+
import pytest
+
from sortedcollections import ItemSortedDict
+
def key_func(key, value):
return key
+
def value_func(key, value):
return value
+
alphabet = 'abcdefghijklmnopqrstuvwxyz'
+
def test_init():
temp = ItemSortedDict(key_func)
temp._check()
+
def test_init_args():
temp = ItemSortedDict(key_func, enumerate(alphabet))
assert len(temp) == 26
@@ -24,6 +31,7 @@
assert temp.keys()[4] == 4
temp._check()
+
def test_init_kwargs():
temp = ItemSortedDict(key_func, a=0, b=1, c=2)
assert len(temp) == 3
@@ -31,22 +39,26 @@
assert temp.keys()[0] == 'a'
temp._check()
+
def test_getitem():
temp = ItemSortedDict(value_func, enumerate(reversed(alphabet)))
assert temp[0] == 'z'
assert temp.keys()[0] == 25
assert list(temp) == list(reversed(range(26)))
+
def test_delitem():
temp = ItemSortedDict(value_func, enumerate(reversed(alphabet)))
del temp[25]
assert temp.keys()[0] == 24
+
def test_delitem_error():
temp = ItemSortedDict(value_func, enumerate(reversed(alphabet)))
with pytest.raises(KeyError):
del temp[-1]
+
def test_setitem():
temp = ItemSortedDict(value_func, enumerate(reversed(alphabet)))
temp[25] = '!'
@@ -56,18 +68,21 @@
temp[25] = 'a'
assert iloc[0] == 25
+
def test_copy():
temp = ItemSortedDict(value_func, enumerate(reversed(alphabet)))
that = temp.copy()
assert temp == that
assert temp._key != that._key
+
def test_deepcopy():
temp = ItemSortedDict(value_func, enumerate(reversed(alphabet)))
that = copy.deepcopy(temp)
assert temp == that
assert temp._key != that._key
+
def test_update():
temp = ItemSortedDict(lambda key, value: value)
for index, letter in enumerate(alphabet):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-sortedcollections-1.2.1/tests/test_nearestdict.py
new/python-sortedcollections-2.1.0/tests/test_nearestdict.py
--- old/python-sortedcollections-1.2.1/tests/test_nearestdict.py
1970-01-01 01:00:00.000000000 +0100
+++ new/python-sortedcollections-2.1.0/tests/test_nearestdict.py
2021-01-18 23:01:45.000000000 +0100
@@ -0,0 +1,72 @@
+import pytest
+
+from sortedcollections import NearestDict
+
+
+def test_basic():
+ d = NearestDict()
+
+ with pytest.raises(KeyError):
+ d[0]
+
+ d[0] = 'a'
+ assert d[0] == 'a'
+ d[0] = 'b'
+ assert d[0] == 'b'
+
+
+def test_iteration():
+ # In sorted order by key
+ exp_items = (
+ (0, 'a'),
+ (1, 'b'),
+ (2, 'c'),
+ )
+
+ d = NearestDict()
+ for k, v in exp_items:
+ d[k] = v
+
+ for act, exp in zip(d.items(), exp_items):
+ assert act == exp
+
+
+def test_nearest():
+ d = NearestDict(rounding=NearestDict.NEAREST)
+
+ d[0] = 'a'
+ d[3] = 'b'
+ assert d[-1] == 'a'
+ assert d[0] == 'a'
+ assert d[1] == 'a'
+ assert d[2] == 'b'
+ assert d[3] == 'b'
+ assert d[4] == 'b'
+
+
+def test_nearest_prev():
+ d = NearestDict(rounding=NearestDict.NEAREST_PREV)
+
+ d[0] = 'a'
+ d[3] = 'b'
+ with pytest.raises(KeyError):
+ d[-1]
+ assert d[0] == 'a'
+ assert d[1] == 'a'
+ assert d[2] == 'a'
+ assert d[3] == 'b'
+ assert d[4] == 'b'
+
+
+def test_nearest_next():
+ d = NearestDict(rounding=NearestDict.NEAREST_NEXT)
+
+ d[0] = 'a'
+ d[3] = 'b'
+ assert d[-1] == 'a'
+ assert d[0] == 'a'
+ assert d[1] == 'b'
+ assert d[2] == 'b'
+ assert d[3] == 'b'
+ with pytest.raises(KeyError):
+ d[4]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-sortedcollections-1.2.1/tests/test_ordereddict.py
new/python-sortedcollections-2.1.0/tests/test_ordereddict.py
--- old/python-sortedcollections-1.2.1/tests/test_ordereddict.py
2020-06-07 21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/tests/test_ordereddict.py
2021-01-18 23:01:45.000000000 +0100
@@ -1,11 +1,14 @@
"Test sortedcollections.OrderedDict"
import pickle
+
import pytest
+
from sortedcollections import OrderedDict
pairs = dict(enumerate(range(10)))
+
def test_init():
od = OrderedDict()
assert len(od) == 0
@@ -20,14 +23,18 @@
assert len(od) == 10
od._check()
+
def test_setitem():
od = OrderedDict()
od['alice'] = 0
od['bob'] = 1
od['carol'] = 2
assert len(od) == 3
+ od['carol'] = 2
+ assert len(od) == 3
od._check()
+
def test_delitem():
od = OrderedDict(pairs)
assert len(od) == 10
@@ -36,12 +43,14 @@
assert len(od) == 0
od._check()
+
def test_iter_reversed():
od = OrderedDict([('b', 0), ('a', 1), ('c', 2)])
assert list(od) == ['b', 'a', 'c']
assert list(reversed(od)) == ['c', 'a', 'b']
od._check()
+
def test_clear():
od = OrderedDict(pairs)
assert len(od) == 10
@@ -49,6 +58,7 @@
assert len(od) == 0
od._check()
+
def test_popitem():
od = OrderedDict(enumerate(range(10)))
for num in reversed(range(10)):
@@ -62,12 +72,14 @@
assert num == key == value
od._check()
+
def test_keys():
od = OrderedDict(enumerate(range(10)))
assert list(reversed(od.keys())) == list(reversed(range(10)))
assert od.keys()[:3] == [0, 1, 2]
od._check()
+
def test_items():
items = list(enumerate(range(10)))
od = OrderedDict(enumerate(range(10)))
@@ -75,12 +87,14 @@
assert od.items()[:3] == [(0, 0), (1, 1), (2, 2)]
od._check()
+
def test_values():
od = OrderedDict(enumerate(range(10)))
assert list(reversed(od.values())) == list(reversed(range(10)))
assert od.values()[:3] == [0, 1, 2]
od._check()
+
def test_iloc():
od = OrderedDict(enumerate(range(10)))
iloc = od.keys()
@@ -90,6 +104,7 @@
assert len(iloc) == 10
od._check()
+
def test_pop():
od = OrderedDict(enumerate(range(10)))
for num in range(10):
@@ -99,43 +114,50 @@
assert od.pop(1, default='thing') == 'thing'
od._check()
+
def test_pop_error():
od = OrderedDict()
with pytest.raises(KeyError):
od.pop(0)
+
def test_setdefault():
od = OrderedDict()
od.setdefault(0, False)
- assert od[0] == False
+ assert od[0] is False
od.setdefault(1, default=True)
- assert od[1] == True
+ assert od[1] is True
od.setdefault(2)
- assert od[2] == None
- assert od.setdefault(0) == False
- assert od.setdefault(1) == True
+ assert od[2] is None
+ assert od.setdefault(0) is False
+ assert od.setdefault(1) is True
+
def test_repr():
od = OrderedDict()
assert repr(od) == 'OrderedDict([])'
assert str(od) == 'OrderedDict([])'
+
def test_reduce():
od = OrderedDict(enumerate(range(10)))
data = pickle.dumps(od)
copy = pickle.loads(data)
assert od == copy
+
def test_copy():
od = OrderedDict(enumerate(range(10)))
copy = od.copy()
assert od == copy
+
def test_fromkeys():
od = OrderedDict.fromkeys('abc')
assert od == {'a': None, 'b': None, 'c': None}
od._check()
+
def test_equality():
od = OrderedDict.fromkeys('abc')
assert od == {'a': None, 'b': None, 'c': None}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-sortedcollections-1.2.1/tests/test_orderedset.py
new/python-sortedcollections-2.1.0/tests/test_orderedset.py
--- old/python-sortedcollections-1.2.1/tests/test_orderedset.py 2020-06-07
21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/tests/test_orderedset.py 2021-01-18
23:01:45.000000000 +0100
@@ -1,7 +1,9 @@
"Test sortedcollections.OrderedSet."
-import pytest
import random
+
+import pytest
+
from sortedcollections import OrderedSet
@@ -9,6 +11,7 @@
os = OrderedSet()
assert len(os) == 0
+
def test_contains():
os = OrderedSet(range(100))
assert len(os) == 100
@@ -18,6 +21,7 @@
assert -1 not in os
assert 100 not in os
+
def test_iter():
os = OrderedSet(range(100))
assert list(os) == list(range(100))
@@ -25,6 +29,7 @@
os = OrderedSet(names)
assert list(os) == names
+
def test_reversed():
os = OrderedSet(range(100))
assert list(reversed(os)) == list(reversed(range(100)))
@@ -32,6 +37,7 @@
os = OrderedSet(names)
assert list(reversed(os)) == list(reversed(names))
+
def test_getitem():
values = list(range(100))
random.shuffle(values)
@@ -40,6 +46,7 @@
for index in range(len(os)):
assert os[index] == values[index]
+
def test_index():
values = list(range(100))
random.shuffle(values)
@@ -48,25 +55,31 @@
for value in values:
assert values.index(value) == os.index(value)
+
def test_index_error():
os = OrderedSet(range(10))
with pytest.raises(ValueError):
os.index(10)
+
def test_add():
os = OrderedSet()
for value in range(100):
os.add(value)
assert len(os) == 100
+ os.add(0)
+ assert len(os) == 100
for value in range(100):
assert value in os
+
def test_discard():
os = OrderedSet(range(100))
for value in range(200):
os.discard(value)
assert len(os) == 0
+
def test_repr():
os = OrderedSet()
assert repr(os) == 'OrderedSet([])'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/tests/test_recipes.py
new/python-sortedcollections-2.1.0/tests/test_recipes.py
--- old/python-sortedcollections-1.2.1/tests/test_recipes.py 2020-06-07
21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/tests/test_recipes.py 2021-01-18
23:01:45.000000000 +0100
@@ -1,6 +1,9 @@
"Test sortedcollections.recipes"
+import pickle
+
import pytest
+
from sortedcollections import IndexableDict, IndexableSet, SegmentList
@@ -10,11 +13,20 @@
for value in range(10):
assert iloc[value] == value
+
def test_index_set():
set_values = IndexableSet(range(10))
for index in range(10):
assert set_values[index] == index
+
+def test_index_set_pickle():
+ set_values1 = IndexableSet(range(10))
+ data = pickle.dumps(set_values1)
+ set_values2 = pickle.loads(data)
+ assert set_values1 == set_values2
+
+
def test_segment_list():
values = [5, 1, 3, 2, 4, 8, 6, 7, 9, 0]
sl = SegmentList(values)
@@ -35,11 +47,13 @@
sl.insert(6, 'e')
assert list(sl) == [0, 1, 'c', 'd', 3, 4, 'e']
+
def test_segment_list_bisect():
sl = SegmentList()
with pytest.raises(NotImplementedError):
sl.bisect(0)
+
def test_segment_list_setitem_slice():
sl = SegmentList()
with pytest.raises(NotImplementedError):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-sortedcollections-1.2.1/tests/test_valuesorteddict.py
new/python-sortedcollections-2.1.0/tests/test_valuesorteddict.py
--- old/python-sortedcollections-1.2.1/tests/test_valuesorteddict.py
2020-06-07 21:53:14.000000000 +0200
+++ new/python-sortedcollections-2.1.0/tests/test_valuesorteddict.py
2021-01-18 23:01:45.000000000 +0100
@@ -1,19 +1,24 @@
"Test sortedcollections.ValueSortedDict"
-import copy
import pickle
+
import pytest
+
from sortedcollections import ValueSortedDict
+
def identity(value):
return value
+
alphabet = 'abcdefghijklmnopqrstuvwxyz'
+
def test_init():
temp = ValueSortedDict()
temp._check()
+
def test_init_args():
temp = ValueSortedDict(enumerate(alphabet))
assert len(temp) == 26
@@ -22,6 +27,7 @@
assert temp.keys()[4] == 4
temp._check()
+
def test_init_kwargs():
temp = ValueSortedDict(None, a=0, b=1, c=2)
assert len(temp) == 3
@@ -29,22 +35,26 @@
assert temp.keys()[0] == 'a'
temp._check()
+
def test_getitem():
temp = ValueSortedDict(identity, enumerate(reversed(alphabet)))
assert temp[0] == 'z'
assert temp.keys()[0] == 25
assert list(temp) == list(reversed(range(26)))
+
def test_delitem():
temp = ValueSortedDict(identity, enumerate(reversed(alphabet)))
del temp[25]
assert temp.keys()[0] == 24
+
def test_delitem_error():
temp = ValueSortedDict(identity, enumerate(reversed(alphabet)))
with pytest.raises(KeyError):
del temp[-1]
+
def test_setitem():
temp = ValueSortedDict(identity, enumerate(reversed(alphabet)))
temp[25] = '!'
@@ -53,28 +63,34 @@
temp[25] = 'a'
assert temp.keys()[0] == 25
+
def test_copy():
temp = ValueSortedDict(identity, enumerate(reversed(alphabet)))
that = temp.copy()
assert temp == that
assert temp._key != that._key
+
def test_pickle():
original = ValueSortedDict(identity, enumerate(reversed(alphabet)))
data = pickle.dumps(original)
duplicate = pickle.loads(data)
assert original == duplicate
-class Negater(object):
+
+class Negater:
def __call__(self, value):
return -value
+
def __repr__(self):
return 'negate'
+
def test_repr():
temp = ValueSortedDict(Negater())
assert repr(temp) == 'ValueSortedDict(negate, {})'
+
def test_update():
temp = ValueSortedDict()
for index, letter in enumerate(alphabet):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-sortedcollections-1.2.1/tox.ini
new/python-sortedcollections-2.1.0/tox.ini
--- old/python-sortedcollections-1.2.1/tox.ini 2020-06-07 21:53:14.000000000
+0200
+++ new/python-sortedcollections-2.1.0/tox.ini 2021-01-18 23:01:45.000000000
+0100
@@ -1,17 +1,74 @@
[tox]
-envlist=py27,py34,py35,py36,py37,pypy,pypy3,lint
+envlist=bluecheck,doc8,docs,isortcheck,flake8,mypy,pylint,rstcheck,py36,py37,py38,py39
skip_missing_interpreters=True
[testenv]
-deps=pytest
-commands=python -m pytest
+commands=pytest
+deps=
+ pytest
+ pytest-cov
-[pytest]
-addopts=
- --doctest-modules
- --doctest-glob "*.rst"
-testpaths=docs sortedcollections tests
+[testenv:blue]
+commands=blue {toxinidir}/setup.py {toxinidir}/sortedcollections
{toxinidir}/tests
+deps=blue
+
+[testenv:bluecheck]
+commands=blue --check {toxinidir}/setup.py {toxinidir}/sortedcollections
{toxinidir}/tests
+deps=blue
+
+[testenv:doc8]
+deps=doc8
+commands=doc8 docs
+
+[testenv:docs]
+allowlist_externals=make
+changedir=docs
+commands=make html
+deps=sphinx
+
+[testenv:flake8]
+commands=flake8 {toxinidir}/setup.py {toxinidir}/sortedcollections
{toxinidir}/tests
+deps=flake8
+
+[testenv:isort]
+commands=isort {toxinidir}/setup.py {toxinidir}/sortedcollections
{toxinidir}/tests
+deps=isort
+
+[testenv:isortcheck]
+commands=isort --check {toxinidir}/setup.py {toxinidir}/sortedcollections
{toxinidir}/tests
+deps=isort
-[testenv:lint]
+[testenv:mypy]
+commands=mypy {toxinidir}/sortedcollections
+deps=mypy
+
+[testenv:pylint]
+commands=pylint {toxinidir}/sortedcollections
deps=pylint
-commands=pylint sortedcollections
+
+[testenv:rstcheck]
+commands=rstcheck {toxinidir}/README.rst
+deps=rstcheck
+
+[testenv:uploaddocs]
+allowlist_externals=rsync
+changedir=docs
+commands=
+ rsync -azP --stats --delete _build/html/ \
+
grantjenks.com:/srv/www/www.grantjenks.com/public/docs/sortedcollections/
+
+[isort]
+multi_line_output = 3
+include_trailing_comma = True
+force_grid_wrap = 0
+use_parentheses = True
+ensure_newline_before_comments = True
+line_length = 79
+
+[pytest]
+addopts=
+ --cov-branch
+ --cov-fail-under=100
+ --cov-report=term-missing
+ --cov=sortedcollections
+ --doctest-glob="*.rst"