@@ -146,9 +146,9 @@ def VerifyNativeApiHeadersListIsValid(input_api, output_api):
146146 if non_existing_paths :
147147 return [
148148 output_api .PresubmitError (
149- 'Directories to native API headers have changed which has made the '
150- 'list in PRESUBMIT.py outdated.\n Please update it to the current '
151- 'location of our native APIs.' , non_existing_paths )
149+ 'Directories to native API headers have changed which has made '
150+ 'the list in PRESUBMIT.py outdated.\n Please update it to the '
151+ 'current location of our native APIs.' , non_existing_paths )
152152 ]
153153 return []
154154
@@ -212,10 +212,10 @@ def CheckNoIOStreamInHeaders(input_api, output_api, source_file_filter):
212212 if len (files ):
213213 return [
214214 output_api .PresubmitError (
215- 'Do not #include <iostream> in header files, since it inserts static '
216- +
217- 'initialization into every file including the header. Instead, '
218- + '#include <ostream>. See http://crbug.com/94794' , files )
215+ 'Do not #include <iostream> in header files, since it inserts '
216+ 'static initialization into every file including the header. '
217+ 'Instead, #include <ostream>. See http://crbug.com/94794' ,
218+ files )
219219 ]
220220 return []
221221
@@ -237,15 +237,15 @@ def CheckNoPragmaOnce(input_api, output_api, source_file_filter):
237237 return [
238238 output_api .PresubmitError (
239239 'Do not use #pragma once in header files.\n '
240- 'See http://www.chromium.org/developers/coding-style#TOC-File-headers' ,
240+ 'See http://www.chromium.org/developers/coding-style'
241+ '#TOC-File-headers' ,
241242 files )
242243 ]
243244 return []
244245
245-
246- def CheckNoFRIEND_TEST (
246+ def CheckNoFRIEND_TEST (# pylint: disable=invalid-name
247247 input_api ,
248- output_api , # pylint: disable=invalid-name
248+ output_api ,
249249 source_file_filter ):
250250 """Make sure that gtest's FRIEND_TEST() macro is not used, the
251251 FRIEND_TEST_ALL_PREFIXES() macro from testsupport/gtest_prod_util.h should be
@@ -263,9 +263,9 @@ def CheckNoFRIEND_TEST(
263263 return []
264264 return [
265265 output_api .PresubmitPromptWarning (
266- 'WebRTC\' s code should not use '
267- 'gtest \' s FRIEND_TEST() macro. Include testsupport/gtest_prod_util.h and '
268- 'use FRIEND_TEST_ALL_PREFIXES() instead.\n ' + '\n ' .join (problems ))
266+ 'WebRTC\' s code should not use gtest \' s FRIEND_TEST() macro. '
267+ 'Include testsupport/gtest_prod_util.h and use '
268+ 'FRIEND_TEST_ALL_PREFIXES() instead.\n ' + '\n ' .join (problems ))
269269 ]
270270
271271
@@ -346,9 +346,9 @@ def CheckNoSourcesAbove(input_api, gn_files, output_api):
346346 if violating_gn_files :
347347 return [
348348 output_api .PresubmitError (
349- 'Referencing source files above the directory of the GN file is not '
350- 'allowed. Please introduce new GN targets in the proper location '
351- 'instead.\n '
349+ 'Referencing source files above the directory of the GN file '
350+ 'is not allowed. Please introduce new GN targets in the proper '
351+ 'location instead.\n '
352352 'Invalid source entries:\n '
353353 '%s\n '
354354 'Violating GN files:' % '\n ' .join (violating_source_entries ),
@@ -407,9 +407,9 @@ def _MoreThanOneSourceUsed(*sources_lists):
407407 gn_file_content = input_api .ReadFile (gn_file )
408408 for target_match in TARGET_RE .finditer (gn_file_content ):
409409 # list_of_sources is a list of tuples of the form
410- # (c_files, cc_files, objc_files) that keeps track of all the sources
411- # defined in a target. A GN target can have more that on definition of
412- # sources (since it supports if/else statements).
410+ # (c_files, cc_files, objc_files) that keeps track of all the
411+ # sources defined in a target. A GN target can have more that
412+ # on definition of sources (since it supports if/else statements).
413413 # E.g.:
414414 # rtc_static_library("foo") {
415415 # if (is_win) {
@@ -454,7 +454,8 @@ def _MoreThanOneSourceUsed(*sources_lists):
454454 return [
455455 output_api .PresubmitError (
456456 'GN targets cannot mix .c, .cc and .m (or .mm) source files.\n '
457- 'Please create a separate target for each collection of sources.\n '
457+ 'Please create a separate target for each collection of '
458+ 'sources.\n '
458459 'Mixed sources: \n '
459460 '%s\n '
460461 'Violating GN files:\n %s\n ' %
@@ -476,8 +477,8 @@ def CheckNoPackageBoundaryViolations(input_api, gn_files, output_api):
476477 if errors :
477478 return [
478479 output_api .PresubmitError (
479- 'There are package boundary violations in the following GN files:' ,
480- long_text = '\n \n ' .join (str (err ) for err in errors ))
480+ 'There are package boundary violations in the following GN '
481+ 'files:' , long_text = '\n \n ' .join (str (err ) for err in errors ))
481482 ]
482483 return []
483484
@@ -491,7 +492,7 @@ def CheckNoWarningSuppressionFlagsAreAdded(gn_files,
491492 input_api ,
492493 output_api ,
493494 error_formatter = _ReportFileAndLine ):
494- """Make sure that warning suppression flags are not added wihtout a reason."""
495+ """Ensure warning suppression flags are not added wihtout a reason."""
495496 msg = ('Usage of //build/config/clang:extra_warnings is discouraged '
496497 'in WebRTC.\n '
497498 'If you are not adding this code (e.g. you are just moving '
@@ -674,7 +675,8 @@ def CheckGnGen(input_api, output_api):
674675 if errors :
675676 return [
676677 output_api .PresubmitPromptWarning (
677- 'Some #includes do not match the build dependency graph. Please run:\n '
678+ 'Some #includes do not match the build dependency graph. '
679+ 'Please run:\n '
678680 ' gn gen --check <out_dir>' ,
679681 long_text = '\n \n ' .join (errors ))
680682 ]
@@ -729,18 +731,20 @@ def CheckUnwantedDependencies(input_api, output_api, source_file_filter):
729731 if error_descriptions :
730732 results .append (
731733 output_api .PresubmitError (
732- 'You added one or more #includes that violate checkdeps rules.\n '
733- 'Check that the DEPS files in these locations contain valid rules.\n '
734- 'See https://cs.chromium.org/chromium/src/buildtools/checkdeps/ for '
735- 'more details about checkdeps.' , error_descriptions ))
734+ 'You added one or more #includes that violate checkdeps rules.'
735+ '\n Check that the DEPS files in these locations contain valid '
736+ 'rules.\n See '
737+ 'https://cs.chromium.org/chromium/src/buildtools/checkdeps/ '
738+ 'for more details about checkdeps.' , error_descriptions ))
736739 if warning_descriptions :
737740 results .append (
738741 output_api .PresubmitPromptOrNotify (
739- 'You added one or more #includes of files that are temporarily\n '
740- 'allowed but being removed. Can you avoid introducing the\n '
741- '#include? See relevant DEPS file(s) for details and contacts.\n '
742- 'See https://cs.chromium.org/chromium/src/buildtools/checkdeps/ for '
743- 'more details about checkdeps.' , warning_descriptions ))
742+ 'You added one or more #includes of files that are temporarily'
743+ '\n allowed but being removed. Can you avoid introducing the\n '
744+ '#include? See relevant DEPS file(s) for details and contacts.'
745+ '\n See '
746+ 'https://cs.chromium.org/chromium/src/buildtools/checkdeps/ '
747+ 'for more details about checkdeps.' , warning_descriptions ))
744748 return results
745749
746750
@@ -787,9 +791,10 @@ def CheckChangeHasBugField(input_api, output_api):
787791 else :
788792 return [
789793 output_api .PresubmitError (
790- 'The "Bug: [bug number]" footer is mandatory. Please create a bug and '
791- 'reference it using either of:\n '
792- ' * https://bugs.webrtc.org - reference it using Bug: webrtc:XXXX\n '
794+ 'The "Bug: [bug number]" footer is mandatory. Please create a '
795+ 'bug and reference it using either of:\n '
796+ ' * https://bugs.webrtc.org - reference it using Bug: '
797+ 'webrtc:XXXX\n '
793798 ' * https://crbug.com - reference it using Bug: chromium:XXXXXX'
794799 )
795800 ]
@@ -911,10 +916,19 @@ def CommonChecks(input_api, output_api):
911916 results .extend (
912917 input_api .canned_checks .CheckLicense (input_api , output_api ,
913918 _LicenseHeader (input_api )))
919+
920+ # TODO(bugs.webrtc.org/12114): Delete this filter and run pylint on
921+ # all python files. This is a temporary solution.
922+ python_file_filter = lambda f : (f .LocalPath ().endswith ('.py' ) and
923+ source_file_filter (f ))
924+ python_changed_files = [f .LocalPath () for f in input_api .AffectedFiles (
925+ file_filter = python_file_filter )]
926+
914927 results .extend (
915928 input_api .canned_checks .RunPylint (
916929 input_api ,
917930 output_api ,
931+ files_to_check = python_changed_files ,
918932 files_to_skip = (
919933 r'^base[\\\/].*\.py$' ,
920934 r'^build[\\\/].*\.py$' ,
@@ -932,12 +946,13 @@ def CommonChecks(input_api, output_api):
932946 pylintrc = 'pylintrc' ))
933947
934948 # TODO(nisse): talk/ is no more, so make below checks simpler?
935- # WebRTC can't use the presubmit_canned_checks.PanProjectChecks function since
936- # we need to have different license checks in talk/ and webrtc/ directories.
949+ # WebRTC can't use the presubmit_canned_checks.PanProjectChecks function
950+ # since we need to have different license checks
951+ # in talk/ and webrtc/directories.
937952 # Instead, hand-picked checks are included below.
938953
939- # .m and .mm files are ObjC files. For simplicity we will consider .h files in
940- # ObjC subdirectories ObjC headers.
954+ # .m and .mm files are ObjC files. For simplicity we will consider
955+ # .h files in ObjC subdirectories ObjC headers.
941956 objc_filter_list = (r'.+\.m$' , r'.+\.mm$' , r'.+objc\/.+\.h$' )
942957 # Skip long-lines check for DEPS and GN files.
943958 build_file_filter_list = (r'.+\.gn$' , r'.+\.gni$' , 'DEPS' )
@@ -1163,9 +1178,9 @@ def CheckAbslMemoryInclude(input_api, output_api, source_file_filter):
11631178 if len (files ):
11641179 return [
11651180 output_api .PresubmitError (
1166- 'Please include "absl/memory/memory.h" header for absl::WrapUnique. \n '
1167- 'This header may or may not be included transitively depending on the '
1168- 'C++ standard version.' , files )
1181+ 'Please include "absl/memory/memory.h" header for '
1182+ 'absl::WrapUnique. \n This header may or may not be included '
1183+ 'transitively depending on the C++ standard version.' , files )
11691184 ]
11701185 return []
11711186
@@ -1343,13 +1358,15 @@ def CheckAddedDepsHaveTargetApprovals(input_api, output_api):
13431358 if input_api .tbr :
13441359 return [
13451360 output_api .PresubmitNotifyResult (
1346- '--tbr was specified, skipping OWNERS check for DEPS additions'
1361+ '--tbr was specified, skipping OWNERS check for DEPS '
1362+ 'additions'
13471363 )
13481364 ]
13491365 if input_api .dry_run :
13501366 return [
13511367 output_api .PresubmitNotifyResult (
1352- 'This is a dry run, skipping OWNERS check for DEPS additions'
1368+ 'This is a dry run, skipping OWNERS check for DEPS '
1369+ 'additions'
13531370 )
13541371 ]
13551372 if not input_api .change .issue :
@@ -1393,8 +1410,8 @@ def StripDeps(path):
13931410 if unapproved_dependencies :
13941411 output_list = [
13951412 output (
1396- 'You need LGTM from owners of depends-on paths in DEPS that were '
1397- 'modified in this CL:\n %s' %
1413+ 'You need LGTM from owners of depends-on paths in DEPS that '
1414+ ' were modified in this CL:\n %s' %
13981415 '\n ' .join (sorted (unapproved_dependencies )))
13991416 ]
14001417 suggested_owners = input_api .owners_client .SuggestOwners (
0 commit comments