Python: Port UnreachableCode.ql

This commit is contained in:
Taus
2026-03-20 13:55:58 +00:00
parent 8fc914f636
commit 60f9ce4ce7

View File

@@ -13,7 +13,7 @@
*/ */
import python import python
private import LegacyPointsTo private import semmle.python.ApiGraphs
predicate typing_import(ImportingStmt is) { predicate typing_import(ImportingStmt is) {
exists(Module m | exists(Module m |
@@ -34,11 +34,7 @@ predicate unique_yield(Stmt s) {
/** Holds if `contextlib.suppress` may be used in the same scope as `s` */ /** Holds if `contextlib.suppress` may be used in the same scope as `s` */
predicate suppression_in_scope(Stmt s) { predicate suppression_in_scope(Stmt s) {
exists(With w | exists(With w |
w.getContextExpr() w.getContextExpr() = API::moduleImport("contextlib").getMember("suppress").getACall().asExpr() and
.(Call)
.getFunc()
.(ExprWithPointsTo)
.pointsTo(Value::named("contextlib.suppress")) and
w.getScope() = s.getScope() w.getScope() = s.getScope()
) )
} }