Skip to content

Commit

Permalink
Merge pull request #1348 from dhermes/updating-lint-tox-rule
Browse files Browse the repository at this point in the history
Updating lint tox rule
  • Loading branch information
dhermes committed Jan 7, 2016
2 parents ee25a8d + 2c4c17e commit 22642cd
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ coverage.xml
system_tests/local_test_setup

# Make sure a generated file isn't accidentally committed.
pylintrc_reduced
scripts/pylintrc_reduced

# Directories used for creating generated PB2 files
generated_python/
Expand Down
39 changes: 39 additions & 0 deletions scripts/pep8_on_repo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2016 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Custom script to run pep8 on gcloud codebase.
This runs pep8 as a script via subprocess but only runs it on the
.py files that are checked in to the repository.
"""


import os
import subprocess


def main():
"""Run pep8 on all Python files in the repository."""
git_root = subprocess.check_output(
['git', 'rev-parse', '--show-toplevel']).strip()
os.chdir(git_root)
python_files = subprocess.check_output(['git', 'ls-files', '*py'])
python_files = python_files.strip().split()

pep8_command = ['pep8'] + python_files
subprocess.call(pep8_command)


if __name__ == '__main__':
main()
19 changes: 0 additions & 19 deletions scripts/pep8_on_repo.sh

This file was deleted.

File renamed without changes.
5 changes: 3 additions & 2 deletions run_pylint.py → scripts/run_pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
'docs/conf.py',
'setup.py',
]
PRODUCTION_RC = 'pylintrc_default'
TEST_RC = 'pylintrc_reduced'
SCRIPTS_DIR = os.path.abspath(os.path.dirname(__file__))
PRODUCTION_RC = os.path.join(SCRIPTS_DIR, 'pylintrc_default')
TEST_RC = os.path.join(SCRIPTS_DIR, 'pylintrc_reduced')
TEST_DISABLED_MESSAGES = [
'attribute-defined-outside-init',
'exec-used',
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ verbose = 1
basepython =
python2.7
commands =
{toxinidir}/scripts/pep8_on_repo.sh
python run_pylint.py
python {toxinidir}/scripts/pep8_on_repo.py
python {toxinidir}/scripts/run_pylint.py
deps =
pep8
pylint
Expand Down

0 comments on commit 22642cd

Please sign in to comment.