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 @@ -2379,6 +2379,24 @@ module Reachability {
23792379 succ = node .getASuccessor ( ) and
23802380 not succ = node .getAnExceptionalSuccessor ( ) and
23812381 not succ .getNode ( ) instanceof Yield
2382+ or
2383+ // True branch of `if False:` or `if TYPE_CHECKING:`
2384+ isAlwaysFalseGuard ( node ) and
2385+ succ = node .getATrueSuccessor ( )
2386+ }
2387+
2388+ /**
2389+ * Holds if `node` is a condition that is always `False` at runtime.
2390+ * This covers `if False:` and `if typing.TYPE_CHECKING:`.
2391+ */
2392+ private predicate isAlwaysFalseGuard ( ControlFlowNode node ) {
2393+ node .getNode ( ) instanceof False
2394+ or
2395+ node =
2396+ API:: moduleImport ( "typing" )
2397+ .getMember ( "TYPE_CHECKING" )
2398+ .getAValueReachableFromSource ( )
2399+ .asCfgNode ( )
23822400 }
23832401
23842402 private predicate startBbLikelyReachable ( BasicBlock b ) {
You can’t perform that action at this time.
0 commit comments