diff options
author | Sen Jiang <senj@google.com> | 2017-08-17 01:26:40 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-08-17 01:26:40 +0000 |
commit | 97972e149dd9c22b13980305477f24be69ba8be3 (patch) | |
tree | a919e102b63ce05e604169b54903e4c587de7cdf | |
parent | fe49310df3a905d60ffdc123ad15f826e289e8e5 (diff) | |
parent | 6abc478494f3bfb112e1d2e4ab1ff7e941667828 (diff) | |
download | repohooks-97972e149dd9c22b13980305477f24be69ba8be3.tar.gz |
pylint: support per-repo pylintrc files. am: 6d58a8136d
am: 6abc478494
Change-Id: I8a8fd19d7ecef6f08c0a26c2a49d44a8aebe31d1
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | tools/pylint.py | 14 |
2 files changed, 10 insertions, 6 deletions
@@ -222,7 +222,7 @@ These are notes for people updating the `pre-upload.py` hook itself: ## TODO/Limitations -* `pylint` should support per-repo pylintrc files. +* `pylint` should support per-directory pylintrc files. * Some checkers operate on the files as they exist in the filesystem. This is not easy to fix because the linters require not just the modified file but the entire repo in order to perform full checks. e.g. `pylint` needs to know what diff --git a/tools/pylint.py b/tools/pylint.py index 45afe64..6091c1d 100755 --- a/tools/pylint.py +++ b/tools/pylint.py @@ -45,12 +45,16 @@ def main(argv): parser = get_parser() opts, unknown = parser.parse_known_args(argv) - pylintrc = DEFAULT_PYLINTRC_PATH if not opts.no_rcfile else None - cmd = [opts.executable_path] - if pylintrc: - # If we pass a non-existent rcfile to pylint, it'll happily ignore it. - assert os.path.exists(pylintrc), 'Could not find %s' % pylintrc + if not opts.no_rcfile: + # We assume pylint is running in the top directory of the project, + # so load the pylintrc file from there if it's available. + pylintrc = os.path.abspath('pylintrc') + if not os.path.exists(pylintrc): + pylintrc = DEFAULT_PYLINTRC_PATH + # If we pass a non-existent rcfile to pylint, it'll happily ignore + # it. + assert os.path.exists(pylintrc), 'Could not find %s' % pylintrc cmd += ['--rcfile', pylintrc] cmd += unknown + opts.files |