3 ms·
If you're returning myVariable instead, that's "fine" - it is always defined. You might get a warning that myVariabl_r_ is unused, but that's also not a given.
by rich_sasha 5y ago
If you're returning myVariable instead, that's "fine" - it is always defined.
You might get a warning that myVariabl_r_ is unused, but that's also not a given. The bar for being 'used' is pretty low. For example, in this
def main():
x = 10
l = []
l.append(x)
return 5
pyflakes believes both x and l are "used", even though neither affects function return value.
- formerly_proven 5y agoIn Python even the trivial definition of "used" (i.e. "bound name which is referred to afterwards") is not that easy (e.g. getattr), linters go for the literal definition instead ("bound name, which is statically referred to afterwards"). This works for 99 % of code. Your definition of "used" (~"influences the observable result") is of course fully within the dominion of Rice's theorem, though this particular example would be caught by any data-flow analyzer.