Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating lint tox rule #1348

Merged
merged 2 commits into from
Jan 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

This comment was marked as spam.

This comment was marked as spam.


# Travis build directories.
gcloud-python-wheels/
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')

This comment was marked as spam.

This comment was marked as spam.

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 @@ -70,8 +70,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