google / mobly

E2E test framework for tests with complex environment requirements.
https://github.com/google/mobly
Apache License 2.0
628 stars 175 forks source link

Fix flake8 warning to meet PEP8 #741

Closed johnklee closed 3 years ago

johnklee commented 3 years ago

With .flake8 setting as below:

[flake8]
ignore = E111,E114
max-line-length = 90

Launch flake8 check below will have below warning:

# flake8 mobly
mobly/base_instrumentation_test.py:577:67: W504 line break after binary operator
mobly/base_instrumentation_test.py:697:30: W503 line break before binary operator
mobly/base_instrumentation_test.py:697:67: W504 line break after binary operator
mobly/base_instrumentation_test.py:721:9: E125 continuation line with same indent as next logical line
mobly/base_instrumentation_test.py:735:7: E125 continuation line with same indent as next logical line
mobly/base_instrumentation_test.py:831:69: W504 line break after binary operator
mobly/base_test.py:839:5: E722 do not use bare 'except'
mobly/utils.py:283:7: E125 continuation line with same indent as next logical line
mobly/utils.py:454:5: E722 do not use bare 'except'
mobly/utils.py:463:3: E722 do not use bare 'except'
mobly/suite_runner.py:100:7: E722 do not use bare 'except'
mobly/test_runner.py:17:1: F401 'inspect' imported but unused
mobly/test_runner.py:80:7: E722 do not use bare 'except'
mobly/test_runner.py:168:3: E722 do not use bare 'except'
mobly/controller_manager.py:122:5: E722 do not use bare 'except'
mobly/controller_manager.py:207:5: E125 continuation line with same indent as next logical line
mobly/logger.py:26:91: E501 line too long (92 > 90 characters)
mobly/records.py:23:1: F401 'sys' imported but unused
mobly/records.py:98:1: F811 redefinition of unused 'Error' from line 38
mobly/records.py:471:5: E741 ambiguous variable name 'l'
mobly/records.py:646:5: E741 ambiguous variable name 'l'
mobly/controllers/android_device.py:133:5: E722 do not use bare 'except'
mobly/controllers/attenuator.py:36:1: F401 'logging' imported but unused
mobly/controllers/attenuator.py:67:5: F841 local variable 'instances' is assigned to but never used
mobly/controllers/monsoon.py:36:1: F401 'mobly.controllers.android_device' imported but unused
mobly/controllers/monsoon.py:147:9: F841 local variable 'e' is assigned to but never used
mobly/controllers/monsoon.py:152:9: F841 local variable 'e' is assigned to but never used
mobly/controllers/monsoon.py:528:9: E741 ambiguous variable name 'l'
mobly/controllers/monsoon.py:755:5: F841 local variable 'history_deque' is assigned to but never used
mobly/controllers/monsoon.py:791:5: F841 local variable 'e' is assigned to but never used
mobly/controllers/monsoon.py:800:5: E722 do not use bare 'except'
mobly/controllers/iperf_server.py:19:1: F401 'subprocess' imported but unused
mobly/controllers/iperf_server.py:31:5: E722 do not use bare 'except'
mobly/controllers/iperf_server.py:40:5: E722 do not use bare 'except'
mobly/controllers/sniffer_lib/local/local_base.py:23:1: F401 'signal' imported but unused
mobly/controllers/sniffer_lib/local/tshark.py:31:53: W504 line break after binary operator
mobly/controllers/sniffer_lib/local/tshark.py:40:12: F524 '...'.format(...) is missing argument(s) for placeholder(s): 1
mobly/controllers/attenuator_lib/telnet_scpi_client.py:73:25: W605 invalid escape sequence '\S'
mobly/controllers/attenuator_lib/telnet_scpi_client.py:79:77: W504 line break after binary operator
mobly/controllers/android_device_lib/snippet_client.py:41:78: W504 line break after binary operator
mobly/controllers/android_device_lib/snippet_client.py:44:74: W504 line break after binary operator
mobly/controllers/android_device_lib/snippet_client.py:132:7: E722 do not use bare 'except'
mobly/controllers/android_device_lib/snippet_client.py:207:5: E722 do not use bare 'except'
mobly/controllers/android_device_lib/snippet_client.py:315:54: W504 line break after binary operator
mobly/controllers/android_device_lib/snippet_client.py:316:11: E129 visually indented line with same indent as next logical line
mobly/controllers/android_device_lib/event_dispatcher.py:65:7: E722 do not use bare 'except'
mobly/controllers/android_device_lib/event_dispatcher.py:272:7: E265 block comment should start with '# '
mobly/controllers/android_device_lib/event_dispatcher.py:295:11: E722 do not use bare 'except'
mobly/controllers/android_device_lib/service_manager.py:18:1: F401 'contextlib' imported but unused
mobly/controllers/android_device_lib/adb.py:37:91: E501 line too long (92 > 90 characters)
mobly/controllers/android_device_lib/jsonrpc_shell_base.py:35:5: F901 'raise NotImplemented' should be 'raise NotImplementedError'
mobly/controllers/android_device_lib/jsonrpc_shell_base.py:42:5: F901 'raise NotImplemented' should be 'raise NotImplementedError'
mobly/controllers/android_device_lib/jsonrpc_client_base.py:48:3: F401 'encodings.idna' imported but unused
mobly/controllers/android_device_lib/jsonrpc_client_base.py:57:1: F401 'sys' imported but unused
mobly/controllers/android_device_lib/sl4a_client.py:110:9: E722 do not use bare 'except'
mobly/controllers/android_device_lib/sl4a_client.py:129:7: E722 do not use bare 'except'
mobly/controllers/android_device_lib/sl4a_client.py:143:7: E722 do not use bare 'except'
mobly/controllers/android_device_lib/services/logcat.py:242:5: E722 do not use bare 'except'

To avoid a large PR, I will divide the commits into multiple PR to reduce the review efforts according to the suggestion from this comment.

johnklee commented 3 years ago

Regarding below warning:

mobly/logger.py:26:91: E501 line too long (92 > 90 characters)

It is caused by a long URL:

 24 LINUX_MAX_FILENAME_LENGTH = 255
 25 # Filename sanitization mappings for Windows.
 26 # See https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
 27 # Although the documentation says that 260 (including terminating nul, so 259)

I prefer not to fix it according to the discussion here

johnklee commented 3 years ago

Part1 fix is ready from below commit: https://github.com/johnklee/mobly/commit/9dc84f158b921184d94576930d9edc10790b7cee

johnklee commented 3 years ago

Part2 fix PR is created: https://github.com/google/mobly/pull/745

johnklee commented 3 years ago

The last part (part2) is fixed and merged. Therefore, close this issue. Many thanks for the help and review from @xpconanfan

xpconanfan commented 3 years ago

Thanks @johnklee for the contributions!