Skip to content

Commit 5c82309

Browse files
committed
tox target to enforce pep8
1 parent c147f66 commit 5c82309

File tree

7 files changed

+44
-18
lines changed

7 files changed

+44
-18
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ env:
99
- TOXENV=py27,codecov
1010
- TOXENV=py27-functional,codecov
1111
- TOXENV=py35-functional,codecov
12+
- TOXENV=update-pep8,codecov
1213
- TOXENV=coverage,codecov
1314

1415
install:

kubernetes/config/kube_config.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919

2020
import urllib3
2121
import yaml
22-
from kubernetes.client import ApiClient, ConfigurationObject, configuration
2322
from oauth2client.client import GoogleCredentials
2423

24+
from kubernetes.client import ApiClient, ConfigurationObject, configuration
25+
2526
from .config_exception import ConfigException
2627

2728
KUBE_CONFIG_DEFAULT_LOCATION = '~/.kube/config'

kubernetes/config/kube_config_test.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
import shutil
1818
import tempfile
1919
import unittest
20+
2021
import yaml
2122
from six import PY3
2223

2324
from .config_exception import ConfigException
2425
from .kube_config import (ConfigNode, FileOrData, KubeConfigLoader,
2526
_cleanup_temp_files, _create_temp_file_with_content,
26-
load_kube_config, list_kube_config_contexts,
27+
list_kube_config_contexts, load_kube_config,
2728
new_client_from_config)
2829

2930
BEARER_TOKEN_FORMAT = "Bearer %s"
@@ -542,7 +543,7 @@ def test_load_kube_config(self):
542543
token=BEARER_TOKEN_FORMAT % TEST_DATA_BASE64)
543544
config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
544545
actual = FakeConfig()
545-
load_kube_config(config_file=config_file,context="simple_token",
546+
load_kube_config(config_file=config_file, context="simple_token",
546547
client_configuration=actual)
547548
self.assertEqual(expected, actual)
548549

scripts/preprocess_spec.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from collections import OrderedDict
2020

2121
import urllib3
22+
2223
from constants import KUBERNETES_BRANCH, SPEC_VERSION
2324

2425
# these four constants are shown as part of this example in []:

scripts/update-pep8.sh

+25-11
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ set -o errexit
2121
set -o nounset
2222
set -o pipefail
2323

24-
if ! which virtualenv > /dev/null 2>&1; then
25-
echo "virtualenv is not installed. run: [sudo] pip install virtualenv"
26-
exit
24+
ENV=${VIRTUAL_ENV:-}
25+
26+
if [[ -z ${ENV} ]]; then
27+
if ! which virtualenv > /dev/null 2>&1; then
28+
echo "virtualenv is not installed. run: [sudo] pip install virtualenv"
29+
exit
30+
fi
2731
fi
2832

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

40-
virtualenv "${SCRIPT_ROOT}/.py"
44+
if [[ -z ${ENV} ]]; then
45+
echo "--- Creating virtualenv"
46+
virtualenv "${SCRIPT_ROOT}/.py"
47+
48+
VIRTUAL_ENV_DISABLE_PROMPT=1; source "${SCRIPT_ROOT}/.py/bin/activate"
49+
trap "deactivate" EXIT SIGINT
4150

42-
VIRTUAL_ENV_DISABLE_PROMPT=1; source "${SCRIPT_ROOT}/.py/bin/activate"
43-
trap "deactivate" EXIT SIGINT
51+
echo "--- Updating tools"
52+
pip install --upgrade pep8
53+
pip install --upgrade autopep8
54+
pip install --upgrade isort
55+
fi
4456

4557
SAVEIFS=$IFS
4658
trap "IFS=$SAVEIFS" EXIT SIGINT
4759
IFS=,
4860

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

51-
echo "--- Updating tools"
52-
pip install --upgrade pep8
53-
pip install --upgrade autopep8
54-
pip install --upgrade isort
55-
5663
echo "--- applying autopep8"
5764
for SOURCE in $SOURCES; do
5865
autopep8 -i -a -a $SOURCE
@@ -69,4 +76,11 @@ for SOURCE in $SOURCES; do
6976
pep8 $SOURCE
7077
done
7178

79+
if [[ ! -z ${ENV} ]]; then
80+
if [[ $(git status --porcelain) != "" ]]; then
81+
git --no-pager diff
82+
exit 1
83+
fi
84+
fi
85+
7286
echo "---Done."

test-requirements.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ randomize>=0.13
66
mock>=2.0.0
77
sphinx>=1.2.1,!=1.3b1,<1.4 # BSD
88
recommonmark
9-
codecov>=1.4.0
9+
codecov>=1.4.0
10+
pep8
11+
autopep8
12+
isort

tox.ini

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
[tox]
22
envlist = py27, py34, py35
33

4-
[testenv:docs]
5-
commands = python setup.py build_sphinx
6-
74
[testenv]
85
passenv = TOXENV CI TRAVIS TRAVIS_*
96
usedevelop = True
@@ -13,6 +10,14 @@ commands =
1310
python -V
1411
nosetests []
1512

13+
[testenv:docs]
14+
commands =
15+
python setup.py build_sphinx
16+
17+
[testenv:update-pep8]
18+
commands =
19+
{toxinidir}/scripts/update-pep8.sh
20+
1621
[testenv:py27-functional]
1722
commands =
1823
python -V

0 commit comments

Comments
 (0)