Skip to content

Commit d509c02

Browse files
committed
Fixed flake8 style violations.
1 parent a2b9088 commit d509c02

File tree

5 files changed

+67
-50
lines changed

5 files changed

+67
-50
lines changed

doc/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
3131
extensions = [
3232
'sphinx.ext.autodoc',
33-
#'sphinx.ext.intersphinx',
33+
# 'sphinx.ext.intersphinx',
3434
]
3535

3636
# autodoc generation is a bit aggressive and a nuisance when doing heavy
@@ -79,4 +79,4 @@
7979
]
8080

8181
# Example configuration for intersphinx: refer to the Python standard library.
82-
#intersphinx_mapping = {'http://docs.python.org/': None}
82+
# intersphinx_mapping = {'http://docs.python.org/': None}

kubernetes_asyncio/e2e_test/test_client.py

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,12 @@ async def test_pod_apis(self):
6060
}
6161
}
6262

63-
resp = await api.create_namespaced_pod(body=pod_manifest,
64-
namespace='default')
63+
resp = await api.create_namespaced_pod(body=pod_manifest, namespace='default')
6564
self.assertEqual(name, resp.metadata.name)
6665
self.assertTrue(resp.status.phase)
6766

6867
while True:
69-
resp = await api.read_namespaced_pod(name=name,
70-
namespace='default')
68+
resp = await api.read_namespaced_pod(name=name, namespace='default')
7169
self.assertEqual(name, resp.metadata.name)
7270
self.assertTrue(resp.status.phase)
7371
if resp.status.phase != 'Pending':
@@ -77,27 +75,26 @@ async def test_pod_apis(self):
7775
exec_command = ['/bin/sh',
7876
'-c',
7977
'for i in $(seq 1 3); do date; done']
80-
resp = await api_ws.connect_get_namespaced_pod_exec(name, 'default',
81-
command=exec_command,
82-
stderr=False, stdin=False,
83-
stdout=True, tty=False)
78+
resp = await api_ws.connect_get_namespaced_pod_exec(
79+
name, 'default', command=exec_command,
80+
stderr=False, stdin=False, stdout=True, tty=False
81+
)
8482
print('EXEC response : %s' % resp)
8583
self.assertEqual(3, len(resp.splitlines()))
8684

8785
exec_command = 'uptime'
88-
resp = await api_ws.connect_post_namespaced_pod_exec(name, 'default',
89-
command=exec_command,
90-
stderr=False, stdin=False,
91-
stdout=True, tty=False)
86+
resp = await api_ws.connect_post_namespaced_pod_exec(
87+
name, 'default', command=exec_command,
88+
stderr=False, stdin=False, stdout=True, tty=False
89+
)
9290
print('EXEC response : %s' % resp)
9391
self.assertEqual(1, len(resp.splitlines()))
9492

9593
resp = await api.list_pod_for_all_namespaces()
9694
number_of_pods = len(resp.items)
9795
self.assertTrue(number_of_pods > 0)
9896

99-
resp = await api.delete_namespaced_pod(name=name, body={},
100-
namespace='default')
97+
resp = await api.delete_namespaced_pod(name=name, body={}, namespace='default')
10198

10299
async def test_service_apis(self):
103100
client = api_client.ApiClient(configuration=self.config)
@@ -115,28 +112,29 @@ async def test_service_apis(self):
115112
'targetPort': 80}],
116113
'selector': {'name': name}}}
117114

118-
resp = await api.create_namespaced_service(body=service_manifest,
119-
namespace='default')
115+
resp = await api.create_namespaced_service(body=service_manifest, namespace='default')
120116
self.assertEqual(name, resp.metadata.name)
121117
self.assertTrue(resp.status)
122118

123-
resp = await api.read_namespaced_service(name=name,
124-
namespace='default')
119+
resp = await api.read_namespaced_service(name=name, namespace='default')
125120
self.assertEqual(name, resp.metadata.name)
126121
self.assertTrue(resp.status)
127122

128-
service_manifest['spec']['ports'] = [{'name': 'new',
129-
'port': 8080,
130-
'protocol': 'TCP',
131-
'targetPort': 8080}]
132-
resp = await api.patch_namespaced_service(body=service_manifest,
133-
name=name,
134-
namespace='default')
123+
service_manifest['spec']['ports'] = [
124+
{'name': 'new',
125+
'port': 8080,
126+
'protocol': 'TCP',
127+
'targetPort': 8080}
128+
]
129+
resp = await api.patch_namespaced_service(
130+
body=service_manifest,
131+
name=name,
132+
namespace='default'
133+
)
135134
self.assertEqual(2, len(resp.spec.ports))
136135
self.assertTrue(resp.status)
137136

138-
resp = await api.delete_namespaced_service(name=name, body={},
139-
namespace='default')
137+
resp = await api.delete_namespaced_service(name=name, body={}, namespace='default')
140138

141139
async def test_replication_controller_apis(self):
142140
client = api_client.ApiClient(configuration=self.config)
@@ -146,17 +144,29 @@ async def test_replication_controller_apis(self):
146144
rc_manifest = {
147145
'apiVersion': 'v1',
148146
'kind': 'ReplicationController',
149-
'metadata': {'labels': {'name': name},
150-
'name': name},
151-
'spec': {'replicas': 2,
152-
'selector': {'name': name},
153-
'template': {'metadata': {
154-
'labels': {'name': name}},
155-
'spec': {'containers': [{
156-
'image': 'nginx',
157-
'name': 'nginx',
158-
'ports': [{'containerPort': 80,
159-
'protocol': 'TCP'}]}]}}}}
147+
'metadata': {
148+
'labels': {'name': name},
149+
'name': name
150+
},
151+
'spec': {
152+
'replicas': 2,
153+
'selector': {
154+
'name': name
155+
},
156+
'template': {
157+
'metadata': {'labels': {'name': name}},
158+
'spec': {
159+
'containers': [
160+
{
161+
'image': 'nginx',
162+
'name': 'nginx',
163+
'ports': [{'containerPort': 80, 'protocol': 'TCP'}]
164+
}
165+
]
166+
}
167+
}
168+
}
169+
}
160170

161171
resp = await api.create_namespaced_replication_controller(
162172
body=rc_manifest, namespace='default')

kubernetes_asyncio/stream/ws_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# under the License.
1212

1313
from kubernetes_asyncio.client import ApiClient
14-
from six.moves.urllib.parse import urlencode, quote_plus, urlparse, urlunparse
14+
from six.moves.urllib.parse import urlencode, urlparse, urlunparse
1515
from kubernetes_asyncio.client.rest import RESTResponse
1616

1717

kubernetes_asyncio/stream/ws_client_test.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from asynctest import CoroutineMock, Mock, TestCase, patch
15+
from asynctest import CoroutineMock, TestCase, patch
1616

1717
from kubernetes_asyncio.stream.ws_client import get_websocket_url, WsResponse
18-
from kubernetes_asyncio import client, config
18+
from kubernetes_asyncio import client
1919
from kubernetes_asyncio.stream import WsApiClient
2020

2121

@@ -53,7 +53,7 @@ async def __anext__(self):
5353
self.iter += 1
5454
if self.iter > 5:
5555
raise StopAsyncIteration
56-
return WsResponse((chr(1)+'mock').encode('utf-8'))
56+
return WsResponse((chr(1) + 'mock').encode('utf-8'))
5757

5858
mock = CoroutineMock()
5959
mock.RESTClientObject.return_value.pool_manager = mock
@@ -67,10 +67,17 @@ async def __anext__(self):
6767
stdout=True, tty=False)
6868

6969
ret = await resp
70-
self.assertEqual(ret, 'mock'*5)
71-
mock.ws_connect.assert_called_once_with('wss://localhost/api/v1/namespaces/namespace/pods/pod/exec?command=mock-command&stderr=True&stdin=False&stdout=True&tty=False',
72-
headers={'sec-websocket-protocol': 'v4.channel.k8s.io', 'Accept': '*/*', 'User-Agent':
73-
'Swagger-Codegen/6.0.0-snapshot/python', 'Content-Type': 'application/json'})
70+
self.assertEqual(ret, 'mock' * 5)
71+
mock.ws_connect.assert_called_once_with(
72+
'wss://localhost/api/v1/namespaces/namespace/pods/pod/exec?'
73+
'command=mock-command&stderr=True&stdin=False&stdout=True&tty=False',
74+
headers={
75+
'sec-websocket-protocol': 'v4.channel.k8s.io',
76+
'Accept': '*/*',
77+
'User-Agent': 'Swagger-Codegen/6.0.0-snapshot/python',
78+
'Content-Type': 'application/json'
79+
}
80+
)
7481

7582

7683
if __name__ == '__main__':

kubernetes_asyncio/watch/watch_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async def test_watch_k8s_empty_response(self):
8484
# Iteration must cease after all valid responses were received.
8585
watch = kubernetes_asyncio.watch.Watch()
8686
cnt = 0
87-
async for _ in watch.stream(fake_api.get_namespaces):
87+
async for _ in watch.stream(fake_api.get_namespaces): # noqa
8888
cnt += 1
8989
self.assertEqual(cnt, len(side_effects))
9090

@@ -137,7 +137,7 @@ async def test_watch_with_exception(self):
137137

138138
with self.assertRaises(KeyError):
139139
watch = kubernetes_asyncio.watch.Watch()
140-
async for e in watch.stream(fake_api.get_namespaces, timeout_seconds=10):
140+
async for e in watch.stream(fake_api.get_namespaces, timeout_seconds=10): # noqa
141141
pass
142142

143143

0 commit comments

Comments
 (0)