Skip to content

Conversation

Copy link

Copilot AI commented Dec 23, 2025

Description

Applies Python best practices (PEP 8) to test assertions in test_control_connection.py:

  • Identity checks: == Noneis None (2 instances)
  • Boolean assertions: == True → direct assertion (2 instances)
  • Assertion order: assert 3 == len(hosts)assert len(hosts) == 3 (1 instance)
# Before
assert host == None
assert host.is_up == True
assert 3 == len(hosts)

# After
assert host is None
assert host.is_up
assert len(hosts) == 3

Pre-review checklist

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • I added relevant tests for new features and bug fixes.
  • All commits compile, pass static checks and pass test.
  • PR description sums up the changes and reasons why they should be introduced.
  • I have provided docstrings for the public items that I want to introduce.
  • I have adjusted the documentation in ./docs/source/.
Original prompt
Please apply the following diffs and create a pull request.
Once the PR is ready, give it a title based on the messages of the fixes being applied.

[{"message":"Use 'is None' instead of '== None' for None comparisons. This follows Python best practices and is more explicit about identity checking.","fixFiles":[{"filePath":"tests/integration/standard/test_control_connection.py","diff":"diff --git a/tests/integration/standard/test_control_connection.py b/tests/integration/standard/test_control_connection.py\n--- a/tests/integration/standard/test_control_connection.py\n+++ b/tests/integration/standard/test_control_connection.py\n@@ -90,7 +90,7 @@\n         \"\"\"\n \n         host = self.cluster.get_control_connection_host()\n-        assert host == None\n+        assert host is None\n \n         self.session = self.cluster.connect()\n         cc_host = self.cluster.control_connection._connection.host\n"}]},{"message":"Use 'is True' instead of '== True' for boolean comparisons, or simply 'assert host.is_up' since it's already a boolean value.","fixFiles":[{"filePath":"tests/integration/standard/test_control_connection.py","diff":"diff --git a/tests/integration/standard/test_control_connection.py b/tests/integration/standard/test_control_connection.py\n--- a/tests/integration/standard/test_control_connection.py\n+++ b/tests/integration/standard/test_control_connection.py\n@@ -97,7 +97,7 @@\n \n         host = self.cluster.get_control_connection_host()\n         assert host.address == cc_host\n-        assert host.is_up == True\n+        assert host.is_up\n \n         # reconnect and make sure that the new host is reflected correctly\n         self.cluster.control_connection._reconnect()\n"}]},{"message":"Use 'is None' instead of '== None' for None comparisons. This follows Python best practices and is more explicit about identity checking.","fixFiles":[{"filePath":"tests/integration/standard/test_control_connection.py","diff":"diff --git a/tests/integration/standard/test_control_connection.py b/tests/integration/standard/test_control_connection.py\n--- a/tests/integration/standard/test_control_connection.py\n+++ b/tests/integration/standard/test_control_connection.py\n@@ -117,7 +117,7 @@\n         self.cluster = TestCluster()\n \n         host = self.cluster.get_control_connection_host()\n-        assert host == None\n+        assert host is None\n \n         self.session = self.cluster.connect()\n         cc_endpoint = self.cluster.control_connection._connection.endpoint\n"}]},{"message":"Use 'is True' instead of '== True' for boolean comparisons, or simply 'assert host.is_up' since it's already a boolean value.","fixFiles":[{"filePath":"tests/integration/standard/test_control_connection.py","diff":"diff --git a/tests/integration/standard/test_control_connection.py b/tests/integration/standard/test_control_connection.py\n--- a/tests/integration/standard/test_control_connection.py\n+++ b/tests/integration/standard/test_control_connection.py\n@@ -124,7 +124,7 @@\n \n         host = self.cluster.get_control_connection_host()\n         assert host.endpoint == cc_endpoint\n-        assert host.is_up == True\n+        assert host.is_up\n         hosts = self.cluster.metadata.all_hosts()\n         assert 3 == len(hosts)\n \n"}]},{"message":"[nitpick] Follow the conventional order for assertions: 'assert len(hosts) == 3' is more readable than 'assert 3 == len(hosts)'.","fixFiles":[{"filePath":"tests/integration/standard/test_control_connection.py","diff":"diff --git a/tests/integration/standard/test_control_connection.py b/tests/integration/standard/test_control_connection.py\n--- a/tests/integration/standard/test_control_connection.py\n+++ b/tests/integration/standard/test_control_connection.py\n@@ -126,7 +126,7 @@\n         assert host.endpoint == cc_endpoint\n         assert host.is_up == True\n         hosts = self.cluster.metadata.all_hosts()\n-        assert 3 == len(hosts)\n+        assert len(hosts) == 3\n \n         for host in hosts:\n             assert 9042 == host.broadcast_rpc_port\n"}]}]

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: mykaul <4655593+mykaul@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix None and boolean comparisons for better clarity Use idiomatic Python comparison operators in test assertions Dec 23, 2025
Copilot AI requested a review from mykaul December 23, 2025 09:38
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.

2 participants