Skip to content

Python: Modernise raise-not-implemented query #20086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

joefarebrother
Copy link
Contributor

Straightforward port away from pointsTo, and documentation updates

@Copilot Copilot AI review requested due to automatic review settings July 17, 2025 20:59
@joefarebrother joefarebrother requested a review from a team as a code owner July 17, 2025 20:59
@joefarebrother joefarebrother added the no-change-note-required This PR does not need a change note label Jul 17, 2025
Copy link
Contributor

@Copilot 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

This PR modernizes the "raise-not-implemented" query by migrating away from the pointsTo API to use the newer ApiGraphs framework, along with updating documentation for clarity.

  • Replaces the deprecated pointsTo-based implementation with ApiGraphs API for detecting NotImplemented usage
  • Updates query name and description to be more descriptive
  • Improves documentation with clearer explanations and additional references

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
NotImplementedIsNotAnException.ql Modernizes query implementation using ApiGraphs instead of pointsTo
NotImplementedIsNotAnException.qhelp Updates documentation with clearer explanations and additional reference links

Copy link
Contributor

github-actions bot commented Jul 17, 2025

QHelp previews:

python/ql/src/Exceptions/NotImplementedIsNotAnException.qhelp

Raising NotImplemented

The constant NotImplemented is not an Exception, but is often confused for NotImplementedError. If it is used as an exception, such as in raise NotImplemented or raise NotImplemented("message"), a TypeError will be raised rather than the expected NotImplemented. This may make debugging more difficult.

NotImplemented should only be used as a special return value for implementing special methods such as __lt__. Code that is not intended to be called should raise NotImplementedError.

Recommendation

If a NotImplementedError is intended to be raised, replace the use of NotImplemented with that. If NotImplemented is intended to be returned rather than raised, replace the raise with return NotImplemented

Example

In the following example, the method wrong will incorrectly raise a TypeError when called. The method right will raise a NotImplementedError.

class Abstract(object):

    def wrong(self):
        # Will raise a TypeError
        raise NotImplemented()

    def right(self):
        raise NotImplementedError()

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation no-change-note-required This PR does not need a change note Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant