|
|
|
|
|
by shadowgovt
1381 days ago
|
|
Pyflakes is better than nothing, but it is the nature of Python itself, IIUC, that it can't guard against variable typos because the mutable nature of the various contexts is such that the code under evaluation can't know if a variable name is referencing something that wasn't monkey-patched into scope via code in another module. There's just no way to know that `if foo:` doesn't reference a foo that's supposed to be on the global scope. (Contrast JavaScript, where `use strict` was added to force explicit reference to non-local scope). |
|
You can explicitly mark a nonlocal or global as well.
Now if your project needs to be impervious to malicious actors, additional safeguards will be needed. But I’ve never encountered this situation in a long career.