Skip to content

Pylint reports some missing functions in cqlshlib#4653

Open
jaibheem wants to merge 3 commits intoapache:trunkfrom
jaibheem:CASSANDRA-20400
Open

Pylint reports some missing functions in cqlshlib#4653
jaibheem wants to merge 3 commits intoapache:trunkfrom
jaibheem:CASSANDRA-20400

Conversation

@jaibheem
Copy link

@jaibheem jaibheem commented Mar 3, 2026

Pylint reports some missing functions in cqlshlib

patch by Jai Bheemsen; reviewed by [Reviewers] for CASSANDRA-20400

The Cassandra Jira

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Addresses Pylint “missing member/function” reports in cqlshlib by adding explicit base-class method stubs and suppressing a known false-positive in the safer scanner implementation.

Changes:

  • Disable Pylint no-member in saferscanner.py to avoid false positives from internal re APIs.
  • Add abstract-style stubs (dequote_*, escape_*) to CqlParsingRuleSet so Pylint can see expected methods.

Reviewed changes

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

File Description
pylib/cqlshlib/saferscanner.py Adds a Pylint suppression for internal re member accesses.
pylib/cqlshlib/cqlhandling.py Adds missing base-class method stubs used by completion/parsing logic.

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

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +21 to +22
# pylint: disable=no-member

Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

The file-wide # pylint: disable=no-member suppresses all no-member checks in this module, which can hide real issues unrelated to the known false-positives from Python's internal re modules. Consider narrowing the suppression to the specific lines/blocks that access re.sre_parse/re.sre_compile/re._parser/re._compiler, or using a more targeted disable with an explanation comment.

Copilot uses AI. Check for mistakes.
Comment on lines +139 to +145
raise NotImplementedError("Subclasses must implement dequote_value")

def escape_value(self, value):
raise NotImplementedError("Subclasses must implement dequote_value")

def escape_name(self, name):
raise NotImplementedError("Subclasses must implement dequote_value")
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

The NotImplementedError messages appear copy/pasted: dequote_name and escape_value both say subclasses must implement dequote_value, which is misleading when these methods are called. Update the messages to reference the correct method name (and consider keeping messages consistent across all four stubs).

Suggested change
raise NotImplementedError("Subclasses must implement dequote_value")
def escape_value(self, value):
raise NotImplementedError("Subclasses must implement dequote_value")
def escape_name(self, name):
raise NotImplementedError("Subclasses must implement dequote_value")
raise NotImplementedError("Subclasses must implement dequote_name")
def escape_value(self, value):
raise NotImplementedError("Subclasses must implement escape_value")
def escape_name(self, name):
raise NotImplementedError("Subclasses must implement escape_name")

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@bschoening bschoening left a comment

Choose a reason for hiding this comment

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

see co-pilot review

@jaibheem
Copy link
Author

updated

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


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

You can also share your feedback on Copilot code review. Take the survey.

@absurdfarce
Copy link

I'm okay with this change but isn't there a decent argument for moving the current impls of the escape and dequote functions from the Cql3ParsingRuleSet subclass and back into the CqlParsingRuleSet superclass? The rules around escaping and quoting are much less likely to change between CQL versions (or at least it seems that way) so a default impl that covers most (all?) CQL versions would seem a reasonable candidate for the parent class. Rule set impls for individual CQL versions could then change if these rules around quoting did change in the future.

Again, I'm not necessarily arguing that we have to make such a change... I'm fine with moving this forward as it stands.

@bschoening
Copy link
Contributor

@absurdfarce @jaibheem sounds like a good idea to move the implementation up to the parent class.

jaibheem and others added 3 commits March 16, 2026 18:58
patch by Jai Bheemsen; reviewed by [Reviewers] for CASSANDRA-20400
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Follow up on review comments to move common quoting/escaping logic
to the parent class for better reusability and cleaner inheritance.

patch by Jai Bheemsen; reviewed by [Reviewers] for CASSANDRA-20400
@jaibheem
Copy link
Author

updated now, can you please take a look?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


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

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +21 to 23
# pylint: disable=no-member

import re
def escape_name(name):
if name is None:
return 'NULL'
return "'%s'" % name.replace("'", "''")
self.assertEqual(CqlRuleSet.escape_value(None), "NULL")

def test_escape_name(self):
self.assertEqual(CqlRuleSet.escape_name("name'with'quote"), "'name''with''quote'")

from .basecase import BaseTestCase
from cqlshlib.cql3handling import CqlRuleSet

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.

4 participants