Files
openide/python/python-psi-impl
Aleksandr.Govenkoandintellij-monorepo-bot 6b8123bc31 [python] PY-82876 Fp Local variable might be referenced before assignment` after an exhaustive pattern check
This commit disables PyUnboundLocalVariableInspection for PSI elements that are "UnreachableByControlFlow". This means that in code blocks that are "ReachableForInspection", but "UnreachableByControlFlow" (such as `assert_never` branch in exhaustive match/case statement) there can appear false negatives (although in very rare specific situations). This solution is a bit hacky, but is the simplest way to combine old DFA analysis used by PyUnboundLocalVariableInspection with reachability analysis in PyDataFlow used by the type inference logic, as they tend to handle ASSERTTYPE:Never instructions differently.

These kinds of problems can also arise for other inspections that disable themselves based on reachability (see PyUnresolvedReferencesVisitor, which does not report unresolved elements in unreachable code). The solution to these problem is subject to discussion and future fixes

GitOrigin-RevId: cefd7c404712d214bd93b882a192c0d581f31514
2025-11-14 15:21:05 +00:00
..