-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b42d21
commit f17a83c
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |