pylint: support per-repo pylintrc files.
am: 6d58a8136d

Change-Id: I6c57413997f9720f6c503821f6ffa5d99d7759c7
diff --git a/README.md b/README.md
index ff97bb4..f25b979 100644
--- a/README.md
+++ b/README.md
@@ -222,7 +222,7 @@
 
 ## 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 @@
     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