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 @@ -2417,6 +2417,24 @@ module Reachability {
24172417 // Exception edge from a node that is unlikely to raise
24182418 unlikelyToRaise ( node ) and
24192419 succ = node .getAnExceptionalSuccessor ( )
2420+ or
2421+ // True branch of `if False:` or `if TYPE_CHECKING:`
2422+ isAlwaysFalseGuard ( node ) and
2423+ succ = node .getATrueSuccessor ( )
2424+ }
2425+
2426+ /**
2427+ * Holds if `node` is a condition that is always `False` at runtime.
2428+ * This covers `if False:` and `if typing.TYPE_CHECKING:`.
2429+ */
2430+ private predicate isAlwaysFalseGuard ( ControlFlowNode node ) {
2431+ node .getNode ( ) instanceof False
2432+ or
2433+ node =
2434+ API:: moduleImport ( "typing" )
2435+ .getMember ( "TYPE_CHECKING" )
2436+ .getAValueReachableFromSource ( )
2437+ .asCfgNode ( )
24202438 }
24212439
24222440 private predicate startBbLikelyReachable ( BasicBlock b ) {
You can’t perform that action at this time.
0 commit comments