Skip to content

Commit be8f5fb

Browse files
committed
Merge pull request #555 from dhermes/restore-pylint-speedup
Restore pylint speedup for PRs
2 parents d17100e + 5a2fac8 commit be8f5fb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

run_pylint.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,12 @@ def get_files_for_linting():
125125
a remote branch to diff against.
126126
"""
127127
diff_base = None
128-
# Temporarily turning off origin/master check since file removed.
129-
if os.getenv('TRAVIS') is None:
128+
if (os.getenv('TRAVIS_BRANCH') == 'master' and
129+
os.getenv('TRAVIS_PULL_REQUEST') != 'false'):
130+
# In the case of a pull request into master, we want to
131+
# diff against HEAD in master.
132+
diff_base = 'origin/master'
133+
elif os.getenv('TRAVIS') is None:
130134
# Only allow specified remote and branch in local dev.
131135
remote = os.getenv('GCLOUD_REMOTE_FOR_LINT')
132136
branch = os.getenv('GCLOUD_BRANCH_FOR_LINT')
@@ -176,6 +180,12 @@ def get_python_files():
176180

177181
def lint_fileset(filenames, rcfile, description):
178182
"""Lints a group of files using a given rcfile."""
183+
# Only lint filenames that exist. For example, 'git diff --name-only'
184+
# could spit out deleted / renamed files. Another alternative could
185+
# be to use 'git diff --name-status' and filter out files with a
186+
# status of 'D'.
187+
filenames = [filename for filename in filenames
188+
if os.path.exists(filename)]
179189
if filenames:
180190
rc_flag = '--rcfile=%s' % (rcfile,)
181191
pylint_shell_command = ['pylint', rc_flag] + filenames

0 commit comments

Comments
 (0)