Python: Fix broken queries

This commit is contained in:
Taus
2025-12-05 13:48:28 +00:00
parent 09e1f8d5ad
commit 6ebaff3fdd
3 changed files with 12 additions and 9 deletions

View File

@@ -471,11 +471,10 @@ Definition getUniqueDefinition(Expr use) {
not result = TLocalDefinition(use) not result = TLocalDefinition(use)
} }
/** A helper class to get suitable locations for attributes */ final class FinalExpr = Expr;
class NiceLocationExpr extends Expr {
/** Gets a textual representation of this element. */
override string toString() { result = this.(Expr).toString() }
/** A helper class to get suitable locations for attributes */
class NiceLocationExpr extends FinalExpr {
/** /**
* Holds if this element is at the specified location. * Holds if this element is at the specified location.
* The location spans column `bc` of line `bl` to * The location spans column `bc` of line `bl` to

View File

@@ -3,8 +3,10 @@
import python import python
import semmle.python.dataflow.new.DataFlow import semmle.python.dataflow.new.DataFlow
final class FinalAstNode = AstNode;
/** A looping construct. */ /** A looping construct. */
abstract class Loop extends AstNode { abstract class Loop extends FinalAstNode {
/** /**
* Gets a loop variable of this loop. * Gets a loop variable of this loop.
* For example, `x` and `y` in `for x,y in pairs: print(x+y)` * For example, `x` and `y` in `for x,y in pairs: print(x+y)`
@@ -13,9 +15,9 @@ abstract class Loop extends AstNode {
} }
/** A `for` loop. */ /** A `for` loop. */
private class ForLoop extends Loop, For { private class ForLoop extends Loop instanceof For {
override Variable getALoopVariable() { override Variable getALoopVariable() {
this.getTarget() = result.getAnAccess().getParentNode*() and this.(For).getTarget() = result.getAnAccess().getParentNode*() and
result.getScope() = this.getScope() result.getScope() = this.getScope()
} }
} }

View File

@@ -59,7 +59,9 @@ predicate ok_to_fail(ImportExpr ie) {
os_specific_import(ie) != get_os() os_specific_import(ie) != get_os()
} }
class VersionTest extends ControlFlowNode { final class FinalControlFlowNode = ControlFlowNode;
class VersionTest extends FinalControlFlowNode {
VersionTest() { VersionTest() {
exists(string name | exists(string name |
name.matches("%version%") and name.matches("%version%") and
@@ -70,7 +72,7 @@ class VersionTest extends ControlFlowNode {
) )
} }
override string toString() { result = "VersionTest" } string toString() { result = "VersionTest" }
} }
/** A guard on the version of the Python interpreter */ /** A guard on the version of the Python interpreter */