Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
7bac207
fix: replace Python 2 iter().next() with next(iter())
mykaul Mar 4, 2026
5169599
fix: replace dead UnicodeDecodeError handlers with isinstance checks
mykaul Mar 4, 2026
07f60f9
fix: materialize filter() result into list for Python 3 safety
mykaul Mar 4, 2026
4adfaf0
remove: dead workaround for CPython bug #10923 (fixed in 3.3)
mykaul Mar 4, 2026
11db11c
refactor: rename __unicode__ to __str__ in cqlengine/statements.py
mykaul Mar 4, 2026
d7770b8
refactor: rename __unicode__ to __str__ in cqlengine/query.py
mykaul Mar 4, 2026
8b1e146
refactor: rename __unicode__ to __str__ in models, functions, operato…
mykaul Mar 4, 2026
da86087
remove: delete UnicodeMixin class and all references
mykaul Mar 4, 2026
c5efe7c
remove: delete 'from __future__ import absolute_import' from 5 files
mykaul Mar 4, 2026
2c79bf8
remove: dead WeakSet fallback and custom implementation
mykaul Mar 4, 2026
22d6027
remove: dead try/except around subprocess import in setup.py
mykaul Mar 4, 2026
6f0026d
refactor: rename __nonzero__ to __bool__ in ResultSet
mykaul Mar 4, 2026
b49d894
remove: delete test_export_keyspace_schema_udts that requires Python 2.7
mykaul Mar 4, 2026
879a840
remove: dead unichr() code blocks guarded by Python 2 version check
mykaul Mar 4, 2026
a8686f9
Remove redundant Python version checks that are always True/False on …
mykaul Mar 4, 2026
54bcb9d
Remove u'' string prefixes from production code
mykaul Mar 4, 2026
5647fb1
Remove u'' string prefixes from test code
mykaul Mar 4, 2026
59b6813
Update stale Python 2 comments and docstrings
mykaul Mar 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,580 changes: 1,824 additions & 756 deletions cassandra/cluster.py

Large diffs are not rendered by default.

804 changes: 564 additions & 240 deletions cassandra/connection.py

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions cassandra/cqlengine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,3 @@ class CQLEngineException(Exception):

class ValidationError(CQLEngineException):
pass


class UnicodeMixin(object):
__str__ = lambda x: x.__unicode__()
28 changes: 18 additions & 10 deletions cassandra/cqlengine/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,26 @@

from datetime import datetime

from cassandra.cqlengine import UnicodeMixin, ValidationError
from cassandra.cqlengine import ValidationError


def get_total_seconds(td):
return td.total_seconds()

class QueryValue(UnicodeMixin):

class QueryValue:
"""
Base class for query filter values. Subclasses of these classes can
be passed into .filter() keyword args
"""

format_string = '%({0})s'
format_string = "%({0})s"

def __init__(self, value):
self.value = value
self.context_id = None

def __unicode__(self):
def __str__(self):
return self.format_string.format(self.context_id)

def set_context_id(self, ctx_id):
Expand All @@ -50,18 +52,18 @@ class BaseQueryFunction(QueryValue):
be passed into .filter() and will be translated into CQL functions in
the resulting query
"""

pass


class TimeUUIDQueryFunction(BaseQueryFunction):

def __init__(self, value):
"""
:param value: the time to create bounding time uuid from
:type value: datetime
"""
if not isinstance(value, datetime):
raise ValidationError('datetime instance is required')
raise ValidationError("datetime instance is required")
super(TimeUUIDQueryFunction, self).__init__(value)

def to_database(self, val):
Expand All @@ -79,7 +81,8 @@ class MinTimeUUID(TimeUUIDQueryFunction):

http://cassandra.apache.org/doc/cql3/CQL-3.0.html#timeuuidFun
"""
format_string = 'MinTimeUUID(%({0})s)'

format_string = "MinTimeUUID(%({0})s)"


class MaxTimeUUID(TimeUUIDQueryFunction):
Expand All @@ -88,7 +91,8 @@ class MaxTimeUUID(TimeUUIDQueryFunction):

http://cassandra.apache.org/doc/cql3/CQL-3.0.html#timeuuidFun
"""
format_string = 'MaxTimeUUID(%({0})s)'

format_string = "MaxTimeUUID(%({0})s)"


class Token(BaseQueryFunction):
Expand All @@ -97,6 +101,7 @@ class Token(BaseQueryFunction):

http://cassandra.apache.org/doc/cql3/CQL-3.0.html#tokenFun
"""

def __init__(self, *values):
if len(values) == 1 and isinstance(values[0], (list, tuple)):
values = values[0]
Expand All @@ -109,8 +114,11 @@ def set_columns(self, columns):
def get_context_size(self):
return len(self.value)

def __unicode__(self):
token_args = ', '.join('%({0})s'.format(self.context_id + i) for i in range(self.get_context_size()))
def __str__(self):
token_args = ", ".join(
"%({0})s".format(self.context_id + i)
for i in range(self.get_context_size())
)
return "token({0})".format(token_args)

def update_context(self, ctx):
Expand Down
Loading