global
variable is undefined PYL-W0601 635 original_sigint_handler = None
636
637 def _start_recording():
638 global screen_record_file_path_on_device 639 print_message('Recording video, press Ctrl+C to end...')
640 screen_record_file_path_on_device = _create_tmp_file('screenrecord', 'mp4')
641 dump_cmd = 'screenrecord --verbose %s ' % screen_record_file_path_on_device
A variable has been defined global in a nested scope which wasn't defined in the global namespace earlier. In this case, python will create the variable in the global namespace. This is confusing and can lead to runtime bugs.
Here's an example:
In [1]: def example():
...: global NOT_VAR
...: NOT_VAR = "Setting value inside `example` function."
...:
In [2]: # Accessing NOT_VAR will cause a `NameError` until `example` is called
In [3]: NOT_VAR
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-3-fc2d63c1ce6d> in <module>
----> 1 NOT_VAR
NameError: name 'NOT_VAR' is not defined
In [4]: # After calling example, the variable is created in the global namespace.
In [5]: example()
In [6]: NOT_VAR
Out[6]: 'Setting value inside `example` function.'