File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
python/ql/lib/semmle/python/dataflow/new/internal Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -2441,6 +2441,24 @@ module Reachability {
24412441 // Exception edge from a node that is unlikely to raise
24422442 unlikelyToRaise ( node ) and
24432443 succ = node .getAnExceptionalSuccessor ( )
2444+ or
2445+ // True branch of `if False:` or `if TYPE_CHECKING:`
2446+ isAlwaysFalseGuard ( node ) and
2447+ succ = node .getATrueSuccessor ( )
2448+ }
2449+
2450+ /**
2451+ * Holds if `node` is a condition that is always `False` at runtime.
2452+ * This covers `if False:` and `if typing.TYPE_CHECKING:`.
2453+ */
2454+ private predicate isAlwaysFalseGuard ( ControlFlowNode node ) {
2455+ node .getNode ( ) instanceof False
2456+ or
2457+ node =
2458+ API:: moduleImport ( "typing" )
2459+ .getMember ( "TYPE_CHECKING" )
2460+ .getAValueReachableFromSource ( )
2461+ .asCfgNode ( )
24442462 }
24452463
24462464 private predicate startBbLikelyReachable ( BasicBlock b ) {
You can’t perform that action at this time.
0 commit comments