Fixing py lint errors
Bug: webrtc:9548
Change-Id: I0daf8dc06fdaac1637c32994ef6ad542ed52202a
Reviewed-on: https://webrtc-review.googlesource.com/90045
Reviewed-by: Oleh Prypin <oprypin@webrtc.org>
Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24068}
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 a52b065..1bd5f0c 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 @@
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 @@
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 5d97c3b..1feec47 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 @@
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 02b2052..e518063 100755
--- a/modules/remote_bitrate_estimator/test/plot_dynamics.py
+++ b/modules/remote_bitrate_estimator/test/plot_dynamics.py
@@ -41,7 +41,7 @@
# 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 6f14999..d6e5129 100755
--- a/presubmit_test.py
+++ b/presubmit_test.py
@@ -237,7 +237,7 @@
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 6d40f78..9809ebe 100644
--- a/pylintrc
+++ b/pylintrc
@@ -20,6 +20,7 @@
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 18b1eb5..81e545d 100755
--- a/tools_webrtc/android/build_aar.py
+++ b/tools_webrtc/android/build_aar.py
@@ -161,9 +161,9 @@
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 9a13723..128a5c0 100644
--- a/tools_webrtc/cpu/cpu_mon.py
+++ b/tools_webrtc/cpu/cpu_mon.py
@@ -61,7 +61,7 @@
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 9ac541a..c28a226 100755
--- a/tools_webrtc/libs/generate_licenses_test.py
+++ b/tools_webrtc/libs/generate_licenses_test.py
@@ -16,8 +16,8 @@
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 3b324da..f50c297 100755
--- a/video/full_stack_tests_plot.py
+++ b/video/full_stack_tests_plot.py
@@ -196,9 +196,9 @@
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 @@
# 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