Skip to content

tox target to enforce pep8 #97

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

Merged
merged 1 commit into from
Jan 13, 2017
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ env:
- TOXENV=py27,codecov
- TOXENV=py27-functional,codecov
- TOXENV=py35-functional,codecov
- TOXENV=update-pep8,codecov
- TOXENV=coverage,codecov

install:
Expand Down
3 changes: 2 additions & 1 deletion kubernetes/config/kube_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

import urllib3
import yaml
from kubernetes.client import ApiClient, ConfigurationObject, configuration
from oauth2client.client import GoogleCredentials

from kubernetes.client import ApiClient, ConfigurationObject, configuration

from .config_exception import ConfigException

KUBE_CONFIG_DEFAULT_LOCATION = '~/.kube/config'
Expand Down
5 changes: 3 additions & 2 deletions kubernetes/config/kube_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
import shutil
import tempfile
import unittest

import yaml
from six import PY3

from .config_exception import ConfigException
from .kube_config import (ConfigNode, FileOrData, KubeConfigLoader,
_cleanup_temp_files, _create_temp_file_with_content,
load_kube_config, list_kube_config_contexts,
list_kube_config_contexts, load_kube_config,
new_client_from_config)

BEARER_TOKEN_FORMAT = "Bearer %s"
Expand Down Expand Up @@ -542,7 +543,7 @@ def test_load_kube_config(self):
token=BEARER_TOKEN_FORMAT % TEST_DATA_BASE64)
config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
actual = FakeConfig()
load_kube_config(config_file=config_file,context="simple_token",
load_kube_config(config_file=config_file, context="simple_token",
client_configuration=actual)
self.assertEqual(expected, actual)

Expand Down
1 change: 1 addition & 0 deletions scripts/preprocess_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from collections import OrderedDict

import urllib3

from constants import KUBERNETES_BRANCH, SPEC_VERSION

# these four constants are shown as part of this example in []:
Expand Down
36 changes: 25 additions & 11 deletions scripts/update-pep8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ set -o errexit
set -o nounset
set -o pipefail

if ! which virtualenv > /dev/null 2>&1; then
echo "virtualenv is not installed. run: [sudo] pip install virtualenv"
exit
ENV=${VIRTUAL_ENV:-}

if [[ -z ${ENV} ]]; then
if ! which virtualenv > /dev/null 2>&1; then
echo "virtualenv is not installed. run: [sudo] pip install virtualenv"
exit
fi
fi

SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
Expand All @@ -37,22 +41,25 @@ pushd "${CLIENT_ROOT}" > /dev/null
CLIENT_ROOT=`pwd`
popd > /dev/null

virtualenv "${SCRIPT_ROOT}/.py"
if [[ -z ${ENV} ]]; then
echo "--- Creating virtualenv"
virtualenv "${SCRIPT_ROOT}/.py"

VIRTUAL_ENV_DISABLE_PROMPT=1; source "${SCRIPT_ROOT}/.py/bin/activate"
trap "deactivate" EXIT SIGINT

VIRTUAL_ENV_DISABLE_PROMPT=1; source "${SCRIPT_ROOT}/.py/bin/activate"
trap "deactivate" EXIT SIGINT
echo "--- Updating tools"
pip install --upgrade pep8
pip install --upgrade autopep8
pip install --upgrade isort
fi

SAVEIFS=$IFS
trap "IFS=$SAVEIFS" EXIT SIGINT
IFS=,

SOURCES="${SCRIPT_ROOT}/../setup.py,${CLIENT_ROOT}/config/*.py,${CLIENT_ROOT}/watch/*.py,${SCRIPT_ROOT}/*.py,${CLIENT_ROOT}/../examples/*.py"

echo "--- Updating tools"
pip install --upgrade pep8
pip install --upgrade autopep8
pip install --upgrade isort

echo "--- applying autopep8"
for SOURCE in $SOURCES; do
autopep8 -i -a -a $SOURCE
Expand All @@ -69,4 +76,11 @@ for SOURCE in $SOURCES; do
pep8 $SOURCE
done

if [[ ! -z ${ENV} ]]; then
if [[ $(git status --porcelain) != "" ]]; then
git --no-pager diff
exit 1
fi
fi

echo "---Done."
5 changes: 4 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ randomize>=0.13
mock>=2.0.0
sphinx>=1.2.1,!=1.3b1,<1.4 # BSD
recommonmark
codecov>=1.4.0
codecov>=1.4.0
pep8
autopep8
isort
11 changes: 8 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[tox]
envlist = py27, py34, py35

[testenv:docs]
commands = python setup.py build_sphinx

[testenv]
passenv = TOXENV CI TRAVIS TRAVIS_*
usedevelop = True
Expand All @@ -13,6 +10,14 @@ commands =
python -V
nosetests []

[testenv:docs]
commands =
python setup.py build_sphinx

[testenv:update-pep8]
commands =
{toxinidir}/scripts/update-pep8.sh
Copy link
Contributor

@mbohlool mbohlool Jan 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On thing that is not clear for me is, do we fail if update-pep8.sh change any file on travis? If we don't we should add verify-pep8.sh the same way we have verify in k8s and call that one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, if you see the update-pep8.sh, we run "git status" and fail if any files need updates


[testenv:py27-functional]
commands =
python -V
Expand Down