remove support for python 2
5 files changed, 24 insertions(+), 33 deletions(-)

M README.md
M nosqlite.py
M setup.py
M tests.py
M tox.ini
M README.md +1 -1
@@ 1,7 1,7 @@ 
 nosqlite.py
 ===========
 
-``nosqlite.py`` is a pure python library for python 2 and 3 (2.6, 2.7, 3.3, and 3.4)
+``nosqlite.py`` is a pure python library for Python 3
 that aims to provide a schemaless wrapper for interacting with sqlite databases.
 Much of the behavior follows how the API for [pymongo](http://api.mongodb.org/python/current)
 works, so those familiar with that library should have a similar experience. Example::

          
M nosqlite.py +14 -17
@@ 6,10 6,6 @@ import re
 import sqlite3
 import sys
 
-try:
-    from itertools import ifilter as filter, imap as map
-except ImportError:  # pragma: no cover Python >= 3.0
-    pass
 
 ASCENDING = False
 DESCENDING = True

          
@@ 23,7 19,7 @@ class MalformedDocument(Exception):
     pass
 
 
-class Connection(object):
+class Connection:
     """
     The high-level connection to a sqlite database. Creating a connection accepts
     the same args and keyword args as the ``sqlite3.connect`` method

          
@@ 77,7 73,7 @@ class Connection(object):
         self.db.execute("drop table if exists %s" % name)
 
 
-class Collection(object):
+class Collection:
     """
     A virtual database table that holds JSON-type documents
     """

          
@@ 143,7 139,7 @@ class Collection(object):
             return self.save(document)
 
         # Check if document is a dict
-        if type(document) != dict:
+        if not isinstance(document, dict):
             raise MalformedDocument('document must be a dictionary, not a %s' % type(document))
 
         # Create it and return a modified one with the id

          
@@ 244,7 240,8 @@ class Collection(object):
         """
         results = []
         query = query or {}
-        if skip == None: skip = 0
+        if skip is None:
+            skip = 0
 
         index_name = ''
         where = ''

          
@@ 331,7 328,7 @@ class Collection(object):
         matches = []  # A list of booleans
         reapply = lambda q: self._apply_query(q, document)
 
-        for field, value in query.items():
+        for field, value in list(query.items()):
             # A more complex query type $and, $or, etc
             if field == '$and':
                 matches.append(all(map(reapply, value)))

          
@@ 344,7 341,7 @@ class Collection(object):
 
             # Invoke a query operator
             elif isinstance(value, dict):
-                for operator, arg in value.items():
+                for operator, arg in list(value.items()):
                     if not self._get_operator_fn(operator)(field, arg, document):
                         matches.append(False)
                         break

          
@@ 430,7 427,7 @@ class Collection(object):
         Get a set of distinct values for the given key excluding an implicit
         None for documents that do not contain the key
         """
-        return set(d[key] for d in filter(lambda d: key in d, self.find()))
+        return set(d[key] for d in [d for d in self.find() if key in d])
 
     def create_index(self, key, reindex=True, sparse=False, unique=False):
         """

          
@@ 559,7 556,7 @@ def _eq(field, value, document):
     """
     try:
         return document.get(field, None) == value
-    except TypeError:  # pragma: no cover Python < 3.0
+    except TypeError:
         return False
 
 

          
@@ 569,7 566,7 @@ def _gt(field, value, document):
     """
     try:
         return document.get(field, None) > value
-    except TypeError:  # pragma: no cover Python < 3.0
+    except TypeError:
         return False
 
 

          
@@ 579,7 576,7 @@ def _lt(field, value, document):
     """
     try:
         return document.get(field, None) < value
-    except TypeError:  # pragma: no cover Python < 3.0
+    except TypeError:
         return False
 
 

          
@@ 590,7 587,7 @@ def _gte(field, value, document):
     """
     try:
         return document.get(field, None) >= value
-    except TypeError:  # pragma: no cover Python < 3.0
+    except TypeError:
         return False
 
 

          
@@ 601,7 598,7 @@ def _lte(field, value, document):
     """
     try:
         return document.get(field, None) <= value
-    except TypeError:  # pragma: no cover Python < 3.0
+    except TypeError:
         return False
 
 

          
@@ 671,7 668,7 @@ def _mod(field, value, document):
     cannot be converted to an integer, this will return False.
     """
     try:
-        divisor, remainder = map(int, value)
+        divisor, remainder = list(map(int, value))
     except (TypeError, ValueError):
         raise MalformedQueryException("'$mod' must accept an iterable: [divisor, remainder]")
 

          
M setup.py +0 -6
@@ 8,13 8,7 @@ setup(name="nosqlite",
       classifiers=['Development Status :: 3 - Alpha',
                    'License :: OSI Approved :: MIT License',
                    'Operating System :: OS Independent',
-                   'Programming Language :: Python',
-                   'Programming Language :: Python :: 2',
-                   'Programming Language :: Python :: 2.6',
-                   'Programming Language :: Python :: 2.7',
                    'Programming Language :: Python :: 3',
-                   'Programming Language :: Python :: 3.3',
-                   'Programming Language :: Python :: 3.4',
                    'Topic :: Software Development :: Libraries :: Python Modules'],
       keywords='nosql sqlite nosqlite',
       author='Shaun Duncan',

          
M tests.py +8 -8
@@ 20,7 20,7 @@ def collection(db, request):
     return nosqlite.Collection(db, 'foo', create=False)
 
 
-class TestConnection(object):
+class TestConnection:
 
     def test_connect(self):
         conn = nosqlite.Connection(':memory:')

          
@@ 61,18 61,18 @@ class TestConnection(object):
     def test_getattr_returns_attribute(self, sqlite):
         conn = nosqlite.Connection()
 
-        assert conn.__getattr__('db') in conn.__dict__.values()
+        assert conn.__getattr__('db') in list(conn.__dict__.values())
 
     @patch('nosqlite.sqlite3')
     def test_getattr_returns_collection(self, sqlite):
         conn = nosqlite.Connection()
         foo = conn.__getattr__('foo')
 
-        assert foo not in conn.__dict__.values()
+        assert foo not in list(conn.__dict__.values())
         assert isinstance(foo, nosqlite.Collection)
 
 
-class TestCollection(object):
+class TestCollection:
 
     def setup(self):
         self.db = sqlite3.connect(':memory:')

          
@@ 440,7 440,7 @@ class TestCollection(object):
 
     @mark.parametrize('strdoc,doc', [
         ('{"foo": "bar"}', {'_id': 1, 'foo': 'bar'}),
-        (u'{"foo": "☃"}', {'_id': 1, 'foo': u'☃'}),
+        ('{"foo": "☃"}', {'_id': 1, 'foo': '☃'}),
     ])
     def test_load(self, strdoc, doc):
         assert doc == self.collection._load(1, strdoc)

          
@@ 573,7 573,7 @@ class TestCollection(object):
     def test_apply_query_all_operator(self):
         query = {'foo': {'$all': [1, 2, 3]}}
 
-        assert self.collection._apply_query(query, {'foo': range(10)})
+        assert self.collection._apply_query(query, {'foo': list(range(10))})
         assert not self.collection._apply_query(query, {'foo': ['bar', 'baz']})
         assert not self.collection._apply_query(query, {'foo': 3})
 

          
@@ 662,7 662,7 @@ class TestCollection(object):
 
     def test_count(self):
         with patch.object(self.collection, 'find'):
-            self.collection.find.return_value = range(10)
+            self.collection.find.return_value = list(range(10))
             assert self.collection.count() == 10
 
     def test_distinct(self):

          
@@ 694,7 694,7 @@ class TestCollection(object):
         assert not nosqlite.Collection(self.db, 'foo', create=False).exists()
 
 
-class TestFindOne(object):
+class TestFindOne:
 
     def test_returns_None_if_collection_does_not_exist(self, collection):
         assert collection.find_one({}) is None

          
M tox.ini +1 -1
@@ 1,5 1,5 @@ 
 [tox]
-envlist = py26, py27, py33, py34
+envlist = py310, py311
 downloadcache = {toxworkdir}/_download/
 
 [testenv]