Skip to content

Commit 22642cd

Browse files
committed
Merge pull request googleapis#1348 from dhermes/updating-lint-tox-rule
Updating lint tox rule
2 parents ee25a8d + 2c4c17e commit 22642cd

6 files changed

Lines changed: 45 additions & 24 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ coverage.xml
4848
system_tests/local_test_setup
4949

5050
# Make sure a generated file isn't accidentally committed.
51-
pylintrc_reduced
51+
scripts/pylintrc_reduced
5252

5353
# Directories used for creating generated PB2 files
5454
generated_python/

scripts/pep8_on_repo.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2016 Google Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Custom script to run pep8 on gcloud codebase.
16+
17+
This runs pep8 as a script via subprocess but only runs it on the
18+
.py files that are checked in to the repository.
19+
"""
20+
21+
22+
import os
23+
import subprocess
24+
25+
26+
def main():
27+
"""Run pep8 on all Python files in the repository."""
28+
git_root = subprocess.check_output(
29+
['git', 'rev-parse', '--show-toplevel']).strip()
30+
os.chdir(git_root)
31+
python_files = subprocess.check_output(['git', 'ls-files', '*py'])
32+
python_files = python_files.strip().split()
33+
34+
pep8_command = ['pep8'] + python_files
35+
subprocess.call(pep8_command)
36+
37+
38+
if __name__ == '__main__':
39+
main()

scripts/pep8_on_repo.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

run_pylint.py renamed to scripts/run_pylint.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@
3636
'docs/conf.py',
3737
'setup.py',
3838
]
39-
PRODUCTION_RC = 'pylintrc_default'
40-
TEST_RC = 'pylintrc_reduced'
39+
SCRIPTS_DIR = os.path.abspath(os.path.dirname(__file__))
40+
PRODUCTION_RC = os.path.join(SCRIPTS_DIR, 'pylintrc_default')
41+
TEST_RC = os.path.join(SCRIPTS_DIR, 'pylintrc_reduced')
4142
TEST_DISABLED_MESSAGES = [
4243
'attribute-defined-outside-init',
4344
'exec-used',

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ verbose = 1
6868
basepython =
6969
python2.7
7070
commands =
71-
{toxinidir}/scripts/pep8_on_repo.sh
72-
python run_pylint.py
71+
python {toxinidir}/scripts/pep8_on_repo.py
72+
python {toxinidir}/scripts/run_pylint.py
7373
deps =
7474
pep8
7575
pylint

0 commit comments

Comments
 (0)