When running my lint, I am getting the error below:
Redefining name 'tmp_file' from outer scope (line 38) (redefined-outer-name)
Here is my snippet of code in that line:
tmp_file = open('../build/' + me_filename + '.js','w')
Advertisement
Answer
That happens because you have a local name identical to a global name. The local name takes precedence, of course, but it hides the global name, makes it inaccesible, and cause confusion to the reader.
Solution
Change the local name. Or maybe the global name, whatever makes more sense. But note that the global name may be part of the public module interface. The local name should be local and thus safe to change.
Unless… your intention is for these names to be the same. Then you will need to declare the name as global
in the local scope:
tmp_file = None def do_something(): global tmp_file # <---- here! tmp_file = open(...)
Without the global
declaration, the local tmp_file
will be unrelated to the global one. Hence the warning.