Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CASSPYTHON-18: removed obsolete checks for python version > 3.7+#1295

Open
bschoening wants to merge 7 commits into
apache:trunkfrom
bschoening:CASSPYTHON-18
Open

CASSPYTHON-18: removed obsolete checks for python version > 3.7+#1295
bschoening wants to merge 7 commits into
apache:trunkfrom
bschoening:CASSPYTHON-18

Conversation

@bschoening

@bschoening bschoening commented May 26, 2026

Copy link
Copy Markdown
Contributor

A recreated version of #1290 (which was closed accidentally)

Comment thread cassandra/cluster.py Outdated
"to hang indefinitely. If you want to use the Eventlet reactor, you "
"need to install the `futurist` package to allow the driver to use "
"the GreenThreadPoolExecutor. See https://github.com/eventlet/eventlet/issues/508 "
"for more details."))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think this was the only point left from our conversation on the prior PR @bschoening. Based on my earlier comment I'm inclined to say we should just remove this check (and executor class set operation) completely.

Whaddya think?

…ars to have fixed

the issue on their side.  Enables removal of futurist dependency in it's entirety.
with self.VerifiedFunction(self, **kwargs) as vf:
fn_meta = self.keyspace_function_meta[vf.signature]
self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*\) RETURNS NULL ON NULL INPUT RETURNS .*")
self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*) RETURNS NULL ON NULL INPUT RETURNS .*")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not trying to remember where this change (and the similar change above) came from. These tests are failing on Jenkins due to these changes... and they're failing when I run the test locally as well.

I think I made these changes and I think I convinced myself that they were okay via local runs... but something went wrong somewhere along the way.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I think I get it... they just need to be raw strings. Working on fixing this now.

@absurdfarce absurdfarce self-requested a review June 12, 2026 20:26
@absurdfarce

Copy link
Copy Markdown
Contributor

Jenkins run for this appears clean (or at least clean of any regressions). @bschoening are you good with this one as it stands? I think this is the last thing we wanted to get in for 3.30.1.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes legacy Python-version conditionals and drops the futurist dependency, simplifying both runtime code and tests now that the driver targets modern Python versions.

Changes:

  • Remove futurist from test dependencies and delete related eventlet-specific executor selection logic.
  • Simplify Cluster initialization to always use concurrent.futures.ThreadPoolExecutor.
  • Remove Python-version-specific branches and tighten up formatting in multiple unit/integration tests.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tox.ini Removes futurist from tox test dependencies.
test-requirements.txt Drops futurist from test requirements.
cassandra/cluster.py Removes _create_thread_pool_executor and uses ThreadPoolExecutor directly.
tests/__init__.py Removes futurist-based executor selection for eventlet tests.
tests/unit/test_row_factories.py Removes old Python-version workaround; updates/loosens namedtuple regression test.
tests/unit/test_policies.py Minor formatting cleanup in assertions.
tests/unit/advanced/test_insights.py Removes Python-version conditional namespace handling and unused imports.
tests/integration/standard/test_metadata.py Removes old skips; updates regex strings to raw literals.
tests/integration/cqlengine/columns/test_validation.py Removes obsolete Python-version branches and applies formatting cleanups.
tests/integration/cqlengine/base.py Removes Python-version conditional aliasing and unused import.
tests/integration/advanced/graph/fluent/__init__.py Removes Python 2 long type handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1089 to 1092

if PROTOCOL_VERSION < 3:
raise unittest.SkipTest(
"Protocol 3.0+ is required for UDT change events, currently testing against %r"
% (PROTOCOL_VERSION,))

if sys.version_info[0:2] != (2, 7):
raise unittest.SkipTest('This test compares static strings generated from dict items, which may change orders. Test with 2.7.')

cluster = TestCluster()
session = cluster.connect()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kinda the point. We no longer test with anything less than 3.x so having this constraint makes no sense.

Comment thread tests/unit/test_row_factories.py

for r in rows:
self.assertEqual(r.col0, self.long_rows[0][0])
named_tuple_factory(self.long_colnames, self.long_rows)

@absurdfarce absurdfarce Jun 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree that this is a no-op as it stands. The underlying issue with PYTHON-893 was that namedtuple() would throw an exception if it were passed more than 255 parameters. unittest will interpret an unhandled exception from a test case as a failure of that test case so just making the call (with appropriately contrived arguments) should be enough to trigger the error if it occurs.

Now, I'm perfectly willing to concede that the error shouldn't occur for versions of Python we're actually testing against since this issue has been resolved in the Python runtime (as referenced in the comments). So what we're guarding against here is a regression in how the Python runtime handles namedtuple() with lots of args. If we decide we aren't worried about that we can absolutely remove this test... but if we are I don't think we need to go through the extra steps suggested by Copilot.

@bschoening bschoening Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this Cython limitation is now explicitly tested upstream (per Python issue18896) in test_collections.py, we probably don't need to duplicate it here. It might just become technical debt/clutter down the road. If you feel strongly about keeping it, though, I'm okay with it!

diff -r 79d52e7d472d -r 7454ca88aacb Lib/test/test_collections.py
--- a/Lib/test/test_collections.py	Fri Dec 16 19:06:51 2016 +0200
+++ b/Lib/test/test_collections.py	Fri Dec 16 19:19:02 2016 +0200
@@ -319,8 +319,7 @@
         self.assertEqual(Dot(1)._replace(d=999), (999,))
         self.assertEqual(Dot(1)._fields, ('d',))
 
-        # n = 5000
-        n = 254 # SyntaxError: more than 255 arguments:
+        n = 5000
         names = list(set(''.join([choice(string.ascii_letters)
                                   for j in range(10)]) for i in range(n)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An entirely reasonable point.

I also just realized that we're already doing something different in this PR! The rationale for removing the warning about the thread pool impl when using eventlet was that eventlet had already fixed the underlying issue so new versions of the driver wouldn't need to worry about older versions. It's a pretty straightforward parallel; if we do it there we probably should do the same in this case.

I have a slight concern for folks upgrading existing applications which may be working off of a dated set of dependencies... that could potentially undermine the approach I argued for with eventlet. But it's going away in the next release anyway (and isn't used much now) so... I'm not super-worried about it.

Regardless, I think we're in agreement on this test; it can just be removed. I'm also going to remove the check logic that was put in place as part of PYTHON-893.


NAMEDTUPLE_CREATION_BUG = sys.version_info >= (3,) and sys.version_info < (3, 7)

class TestNamedTupleFactory(TestCase):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the Co-pilot comment, it seems like the whole test function can be dropped now (post 3.7)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed below. Fundamentally this comes down to whether we want to test for regressions or not.

self.assertEqual(r.col0, self.long_rows[0][0])
named_tuple_factory(self.long_colnames, self.long_rows)

def test_creation_no_warning_on_short_column_list(self):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be dropped also?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually testing a different case; we're validating proper functionality for a shorter (arguably "normal") length column list. I'd argue for something similar to what I said above; if we decide we aren't worried about regressions in the handling of namedtuple args we can delete this file in it's entirety. I'm not arguing for or against it necessarily... I can see arguments both ways.

@absurdfarce

Copy link
Copy Markdown
Contributor

Mentioned to @bschoening in other communication but I'll make a note of it here too; if we remove the test cases above (because Python runtimes we support no longer have this issue) we should probably remove the workaround added for PYTHON-893 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants