Chromium Code Reviews| Index: presubmit_canned_checks.py |
| diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py |
| index 7fbedecef574f15d13bab30b6adcce4d31978989..69b16e6633af9dc6548e70816a864f80355d850b 100644 |
| --- a/presubmit_canned_checks.py |
| +++ b/presubmit_canned_checks.py |
| @@ -626,21 +626,27 @@ def _FetchAllFiles(input_api, white_list, black_list): |
| def RunPylint(input_api, output_api, white_list=None, black_list=None, |
| - disabled_warnings=None): |
| + disabled_warnings=None, extra_paths_list=None): |
| """Run pylint on python files. |
| The default white_list enforces looking only at *.py files. |
| """ |
| white_list = tuple(white_list or ('.*\.py$',)) |
| black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST) |
| + extra_paths_list = extra_paths_list or [] |
| + |
| if input_api.is_committing: |
| error_type = output_api.PresubmitError |
| else: |
| error_type = output_api.PresubmitPromptWarning |
| # Only trigger if there is at least one python file affected. |
| - src_filter = lambda x: input_api.FilterSourceFile(x, white_list, black_list) |
| + rel_path = lambda x : input_api.os_path.join(input_api.os_path.relpath( |
| + input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot()), x) |
| + src_filter = lambda x: input_api.FilterSourceFile( |
| + x, map(rel_path, white_list), map(rel_path, black_list)) |
| if not input_api.AffectedSourceFiles(src_filter): |
| + input_api.logging.info('Skipping pylint: no matching changes.') |
| return [] |
| extra_args = ['--rcfile=%s' % input_api.os_path.join(_HERE, 'pylintrc')] |
| @@ -648,6 +654,7 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None, |
| extra_args.extend(['-d', ','.join(disabled_warnings)]) |
| files = _FetchAllFiles(input_api, white_list, black_list) |
| + input_api.logging.info('Running pylint on: %s', files) |
|
M-A Ruel
2013/01/07 15:32:46
Put this comment after line 659?
Isaac (away)
2013/01/07 18:46:28
Sure, done.
|
| if not files: |
| return [] |
| @@ -655,7 +662,8 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None, |
| # imports. |
| env = input_api.environ.copy() |
| import sys |
| - env['PYTHONPATH'] = input_api.os_path.pathsep.join(sys.path) |
| + env['PYTHONPATH'] = input_api.os_path.pathsep.join( |
| + extra_paths_list + sys.path) |
|
M-A Ruel
2013/01/07 15:32:46
That's a good idea. Should have done that before.
Isaac (away)
2013/01/07 18:46:28
Yeah it lets us avoid a try/finally loop and impor
|
| def run_lint(files): |
| # We can't import pylint directly due to licensing issues, so we run |
| @@ -687,12 +695,8 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None, |
| # different results. input_api.verbose used to be used |
| # to enable this behaviour but differing behaviour in |
| # verbose mode is not desirable. |
| - if True: |
|
M-A Ruel
2013/01/07 15:32:46
While it's odd, leave it there. Because of issues
Isaac (away)
2013/01/07 18:46:28
OK. I added a comment explaining the unreachable c
|
| - result = run_lint(sorted(files)) |
| - else: |
| - for filename in sorted(files): |
| - print('Running pylint on %s' % filename) |
| - result = run_lint([filename]) or result |
| + print('Running pylint on %d files.' % len(files)) |
| + result = run_lint(sorted(files)) |
| if isinstance(result, basestring): |
| return [error_type(result)] |
| elif result: |