From 5d7a4c6692a2eb09a9cb5b99e799538754015d93 Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Mon, 23 Jul 2018 13:58:25 +0200 Subject: [PATCH] Fixing py lint errors Bug: webrtc:9548 Change-Id: I0daf8dc06fdaac1637c32994ef6ad542ed52202a Reviewed-on: https://webrtc-review.googlesource.com/90045 Reviewed-by: Oleh Prypin Reviewed-by: Niklas Enbom Commit-Queue: Artem Titov Cr-Commit-Position: refs/heads/master@{#24068} --- .../audio_network_adaptor/parse_ana_dump.py | 6 +++--- .../quality_assessment/input_signal_creator.py | 2 +- modules/remote_bitrate_estimator/test/plot_dynamics.py | 2 +- presubmit_test.py | 2 +- pylintrc | 1 + tools_webrtc/android/build_aar.py | 6 +++--- tools_webrtc/cpu/cpu_mon.py | 2 +- tools_webrtc/libs/generate_licenses_test.py | 2 +- video/full_stack_tests_plot.py | 10 +++++----- 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/modules/audio_coding/audio_network_adaptor/parse_ana_dump.py b/modules/audio_coding/audio_network_adaptor/parse_ana_dump.py index a52b065f12..1bd5f0c288 100755 --- a/modules/audio_coding/audio_network_adaptor/parse_ana_dump.py +++ b/modules/audio_coding/audio_network_adaptor/parse_ana_dump.py @@ -66,9 +66,9 @@ def ParseAnaDump(dump_file_to_parse): first_time_stamp = None while True: event = GetNextMessageFromFile(file_to_parse) - if event == None: + if event is None: break - if first_time_stamp == None: + if first_time_stamp is None: first_time_stamp = event.timestamp if event.type == debug_dump_pb2.Event.ENCODER_RUNTIME_CONFIG: for decision in event.encoder_runtime_config.DESCRIPTOR.fields: @@ -110,7 +110,7 @@ def main(): action='append') options = parser.parse_args()[0] - if options.dump_file_to_parse == None: + if options.dump_file_to_parse is None: print "No dump file to parse is set.\n" parser.print_help() exit() diff --git a/modules/audio_processing/test/py_quality_assessment/quality_assessment/input_signal_creator.py b/modules/audio_processing/test/py_quality_assessment/quality_assessment/input_signal_creator.py index 5d97c3b2fc..1feec47b4c 100644 --- a/modules/audio_processing/test/py_quality_assessment/quality_assessment/input_signal_creator.py +++ b/modules/audio_processing/test/py_quality_assessment/quality_assessment/input_signal_creator.py @@ -61,7 +61,7 @@ class InputSignalCreator(object): AudioSegment instance. """ assert 0 < frequency <= 24000 - assert 0 < duration + assert duration > 0 template = signal_processing.SignalProcessingUtils.GenerateSilence(duration) return signal_processing.SignalProcessingUtils.GeneratePureTone( template, frequency) diff --git a/modules/remote_bitrate_estimator/test/plot_dynamics.py b/modules/remote_bitrate_estimator/test/plot_dynamics.py index 02b20523e8..e5180634cb 100755 --- a/modules/remote_bitrate_estimator/test/plot_dynamics.py +++ b/modules/remote_bitrate_estimator/test/plot_dynamics.py @@ -41,7 +41,7 @@ def ParsePlotLine(line): # The variable name can contain any non-whitespace character except "#:@" match = re.match(r'([^\s#:@]+)(?:#\d)?:(\d+)@(\S+)', annotated_var) - if match == None: + if match is None: raise ParsePlotLineException("Could not parse variable name, ssrc and \ algorithm name", annotated_var) var_name = match.group(1) diff --git a/presubmit_test.py b/presubmit_test.py index 6f14999230..d6e512954a 100755 --- a/presubmit_test.py +++ b/presubmit_test.py @@ -237,7 +237,7 @@ class CheckNoMixingSourcesTest(unittest.TestCase): self.assertTrue('bar.c' in str(errors[0])) def _AssertNumberOfErrorsWithSources(self, number_of_errors, sources): - assert 3 == len(sources), 'This function accepts a list of 3 source files' + assert len(sources) == 3, 'This function accepts a list of 3 source files' self._GenerateBuildFile(textwrap.dedent(""" rtc_static_library("bar_foo") { sources = [ diff --git a/pylintrc b/pylintrc index 6d40f783ca..9809ebe998 100644 --- a/pylintrc +++ b/pylintrc @@ -20,6 +20,7 @@ disable= I0010, I0011, W0232, + C0413, bad-continuation, broad-except, duplicate-code, diff --git a/tools_webrtc/android/build_aar.py b/tools_webrtc/android/build_aar.py index 18b1eb5c23..81e545d11c 100755 --- a/tools_webrtc/android/build_aar.py +++ b/tools_webrtc/android/build_aar.py @@ -161,9 +161,9 @@ def Build(build_dir, arch, use_goma, extra_gn_args, extra_gn_switches, gn_args_str = '--args=' + ' '.join([ k + '=' + _EncodeForGN(v) for k, v in gn_args.items()] + extra_gn_args) - gn_args = ['gen', output_directory, gn_args_str] - gn_args.extend(extra_gn_switches) - _RunGN(gn_args) + gn_args_list = ['gen', output_directory, gn_args_str] + gn_args_list.extend(extra_gn_switches) + _RunGN(gn_args_list) ninja_args = TARGETS[:] if use_goma: diff --git a/tools_webrtc/cpu/cpu_mon.py b/tools_webrtc/cpu/cpu_mon.py index 9a13723ed2..128a5c0bf6 100644 --- a/tools_webrtc/cpu/cpu_mon.py +++ b/tools_webrtc/cpu/cpu_mon.py @@ -61,7 +61,7 @@ def main(): snapshots = [] while True: snapshot = GrabCpuSamples(sample_count) - if snapshot == None: + if snapshot is None: break snapshots.append(snapshot) diff --git a/tools_webrtc/libs/generate_licenses_test.py b/tools_webrtc/libs/generate_licenses_test.py index 9ac541adf9..c28a226af2 100755 --- a/tools_webrtc/libs/generate_licenses_test.py +++ b/tools_webrtc/libs/generate_licenses_test.py @@ -16,8 +16,8 @@ SRC = os.path.abspath(os.path.join( os.path.dirname((__file__)), os.pardir, os.pardir)) sys.path.append(os.path.join(SRC, 'third_party', 'pymock')) -import mock import unittest +import mock from generate_licenses import LicenseBuilder diff --git a/video/full_stack_tests_plot.py b/video/full_stack_tests_plot.py index 3b324da67b..f50c297b17 100755 --- a/video/full_stack_tests_plot.py +++ b/video/full_stack_tests_plot.py @@ -196,9 +196,9 @@ def AverageOverCycle(values, length): total = [0.0] * length count = [0] * length - for k in range(len(values)): - if values[k] is not None: - total[k % length] += values[k] + for k, val in enumerate(values): + if val is not None: + total[k % length] += val count[k % length] += 1 result = [0.0] * length @@ -386,11 +386,11 @@ def PlotConfigsFromArgs(args): # argparse.ArgumentParser, modified to remember the order of arguments. # Then we traverse the argument list and fill the PlotConfig. args = itertools.groupby(args, lambda x: x in ["-n", "--next"]) - args = list(list(group) for match, group in args if not match) + prep_args = list(list(group) for match, group in args if not match) parser = GetParser() plot_configs = [] - for index, raw_args in enumerate(args): + for index, raw_args in enumerate(prep_args): graph_args = parser.parse_args(raw_args).ordered_args plot_configs.append(_PlotConfigFromArgs(graph_args, index)) return plot_configs