Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c7433af
fix: replace Python 2 iter().next() with next(iter())
mykaul Mar 4, 2026
5193976
fix: replace dead UnicodeDecodeError handlers with isinstance checks
mykaul Mar 4, 2026
7cc7a85
fix: materialize filter() result into list for Python 3 safety
mykaul Mar 4, 2026
93f3d79
remove: dead workaround for CPython bug #10923 (fixed in 3.3)
mykaul Mar 4, 2026
f42b8b8
refactor: rename __unicode__ to __str__ in cqlengine/statements.py
mykaul Mar 4, 2026
227e10a
refactor: rename __unicode__ to __str__ in cqlengine/query.py
mykaul Mar 4, 2026
1a9e974
refactor: rename __unicode__ to __str__ in models, functions, operato…
mykaul Mar 4, 2026
d2fda40
remove: delete UnicodeMixin class and all references
mykaul Mar 4, 2026
e5def77
remove: delete 'from __future__ import absolute_import' from 5 files
mykaul Mar 4, 2026
20dc6a4
remove: dead WeakSet fallback and custom implementation
mykaul Mar 4, 2026
4d97359
remove: dead try/except around subprocess import in setup.py
mykaul Mar 4, 2026
11eead4
refactor: rename __nonzero__ to __bool__ in ResultSet
mykaul Mar 4, 2026
e7f977a
remove: delete test_export_keyspace_schema_udts that requires Python 2.7
mykaul Mar 4, 2026
5b48664
remove: dead unichr() code blocks guarded by Python 2 version check
mykaul Mar 4, 2026
014e847
Remove redundant Python version checks that are always True/False on …
mykaul Mar 4, 2026
36c16d3
Remove u'' string prefixes from production code
mykaul Mar 4, 2026
4af7fa5
Remove u'' string prefixes from test code
mykaul Mar 4, 2026
dd822a9
Update stale Python 2 comments and docstrings
mykaul Mar 4, 2026
8103cf8
fix: replace Python 2 bytes.encode('hex') with bytes.hex()
mykaul Mar 16, 2026
1a39140
Potential fix for pull request finding
mykaul Mar 16, 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
Loading