-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Draft] Python: Modernize the init-calls-subclass query #19709
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
base: main
Are you sure you want to change the base?
[Draft] Python: Modernize the init-calls-subclass query #19709
Conversation
QHelp previews: python/ql/src/Classes/InitCallsSubclass/InitCallsSubclassMethod.qhelp
|
There was a problem hiding this 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 py/init-calls-subclass
QL query by replacing the old implementation with a new dataflow-based approach.
- Removes the legacy
InitCallsSubclassMethod.ql
. - Adds a new directory and file under
InitCallsSubclass/
usingDataFlow
predicates. - Defines two predicates (
initSelfCall
andinitSelfCallOverridden
) to detect subclass-overridden calls in__init__
.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
python/ql/src/Classes/InitCallsSubclassMethod.ql | Deleted the legacy query file |
python/ql/src/Classes/InitCallsSubclass/InitCallsSubclassMethod.ql | Added modernized dataflow-based query implementation |
Comments suppressed due to low confidence (4)
python/ql/src/Classes/InitCallsSubclass/InitCallsSubclassMethod.ql:28
- [nitpick] The parameter name
override
is ambiguous and matches a language keyword. Consider renaming it to something likeoverridingMethod
for clarity.
predicate initSelfCallOverridden(Function init, DataFlow::MethodCallNode call, Function override) {
python/ql/src/Classes/InitCallsSubclass/InitCallsSubclassMethod.ql:18
- [nitpick] It would be helpful to add a brief doc comment above this predicate explaining its purpose and parameters for future maintainers.
predicate initSelfCall(Function init, DataFlow::MethodCallNode call) {
python/ql/src/Classes/InitCallsSubclass/InitCallsSubclassMethod.ql:38
- The new dataflow-based implementation should be accompanied by tests to validate that overridden
__init__
calls are correctly detected; consider adding or updating QL tests.
from Function init, DataFlow::MethodCallNode call, Function override
python/ql/src/Classes/InitCallsSubclass/InitCallsSubclassMethod.ql:16
- This import isn't used in the new query. Consider removing it to keep dependencies minimal.
import semmle.python.dataflow.new.internal.DataFlowDispatch
python/ql/src/Classes/InitCallsSubclass/InitCallsSubclassMethod.ql
Outdated
Show resolved
Hide resolved
…f, or the call is last in the initialisation.
d92aeda
to
0f7a24e
Compare
0f7a24e
to
2aad607
Compare
No description provided.