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 @@ -2396,6 +2396,24 @@ module Reachability {
23962396 // Exception edge from a node that is unlikely to raise
23972397 unlikelyToRaise ( node ) and
23982398 succ = node .getAnExceptionalSuccessor ( )
2399+ or
2400+ // True branch of `if False:` or `if TYPE_CHECKING:`
2401+ isAlwaysFalseGuard ( node ) and
2402+ succ = node .getATrueSuccessor ( )
2403+ }
2404+
2405+ /**
2406+ * Holds if `node` is a condition that is always `False` at runtime.
2407+ * This covers `if False:` and `if typing.TYPE_CHECKING:`.
2408+ */
2409+ private predicate isAlwaysFalseGuard ( ControlFlowNode node ) {
2410+ node .getNode ( ) instanceof False
2411+ or
2412+ node =
2413+ API:: moduleImport ( "typing" )
2414+ .getMember ( "TYPE_CHECKING" )
2415+ .getAValueReachableFromSource ( )
2416+ .asCfgNode ( )
23992417 }
24002418
24012419 private predicate startBbLikelyReachable ( BasicBlock b ) {
You can’t perform that action at this time.
0 commit comments