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 @@ -2446,6 +2446,24 @@ module Reachability {
24462446 // Exception edge from a node that is unlikely to raise
24472447 unlikelyToRaise ( node ) and
24482448 succ = node .getAnExceptionalSuccessor ( )
2449+ or
2450+ // True branch of `if False:` or `if TYPE_CHECKING:`
2451+ isAlwaysFalseGuard ( node ) and
2452+ succ = node .getATrueSuccessor ( )
2453+ }
2454+
2455+ /**
2456+ * Holds if `node` is a condition that is always `False` at runtime.
2457+ * This covers `if False:` and `if typing.TYPE_CHECKING:`.
2458+ */
2459+ private predicate isAlwaysFalseGuard ( ControlFlowNode node ) {
2460+ node .getNode ( ) instanceof False
2461+ or
2462+ node =
2463+ API:: moduleImport ( "typing" )
2464+ .getMember ( "TYPE_CHECKING" )
2465+ .getAValueReachableFromSource ( )
2466+ .asCfgNode ( )
24492467 }
24502468
24512469 private predicate startBbLikelyReachable ( BasicBlock b ) {
You can’t perform that action at this time.
0 commit comments