diff --git a/doc/whatsnew/fragments/1727.false_negative.1 b/doc/whatsnew/fragments/1727.false_negative.1 new file mode 100644 index 0000000000..f462b124e9 --- /dev/null +++ b/doc/whatsnew/fragments/1727.false_negative.1 @@ -0,0 +1,19 @@ +``used-before-assignment`` is now emitted when relying on variable assignments +that were not exhaustively made in every if/else branch. + +If you rely on a pattern like this: +``` +if guarded(): + var = 1 + +if guarded(): + print(var) # now emits used-before-assignment +``` + +...you may be concerned that ``used-before-assignment`` is not totally useful +in this instance. However, consider that pylint, as a static analysis tool, does +not know if ``guarded()`` is deterministic, has side effects, or talks to +a database. (Likewise, for ``guarded`` instead of ``guarded()``, any other +part of your program may have changed the value in the meantime.) + +Closes #1727