Undefined name 'py_args'
cclauss opened this issue · comments
Flake8 F82 tests are almost always undefined names which are usually a sign of a typo, missing imports, or code that has not been ported to Python 3. These also would be compile-time errors in a compiled language but in Python, a NameError may be raised which will halt/crash the script on the user.
https://github.com/google/grr/search?q=py_args
$ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
./grr/core/executables/python_hacks/shutdown_host.py:15:25: F821 undefined name 'py_args'
if 'time_in_seconds' in py_args:
^
./grr/core/executables/python_hacks/shutdown_host.py:16:22: F821 undefined name 'py_args'
args.extend(['/t', py_args['time_in_seconds']])
^
./grr/core/executables/python_hacks/shutdown_host.py:20:16: F821 undefined name 'py_args'
if 'reason' in py_args:
^
./grr/core/executables/python_hacks/shutdown_host.py:21:22: F821 undefined name 'py_args'
args.extend(['/c', py_args['reason']])
^
./grr/core/executables/python_hacks/modify_network.py:112:15: F821 undefined name 'py_args'
if 'msg' in py_args:
^
./grr/core/executables/python_hacks/modify_network.py:113:33: F821 undefined name 'py_args'
return_str['msg'] = MsgUser(py_args['msg'])
^
./grr/core/executables/python_hacks/modify_network.py:123:24: F821 undefined name 'py_args'
if all([key in py_args for key in ['ip', 'subnet', 'gw']]):
^
./grr/core/executables/python_hacks/modify_network.py:125:26: F821 undefined name 'py_args'
interface, py_args['ip'], py_args['subnet'], py_args['gw'])
^
./grr/core/executables/python_hacks/modify_network.py:125:41: F821 undefined name 'py_args'
interface, py_args['ip'], py_args['subnet'], py_args['gw'])
^
./grr/core/executables/python_hacks/modify_network.py:125:60: F821 undefined name 'py_args'
interface, py_args['ip'], py_args['subnet'], py_args['gw'])
^
10 F821 undefined name 'py_args'
10
```
This is not really an issue, since these are all Python hacks that are evaluated in an environment that supplies these variables.