Skip to content

Commit 94c55d0

Browse files
committed
Fix PEP8 style failures
1 parent 9c9db8c commit 94c55d0

File tree

6 files changed

+31
-17
lines changed

6 files changed

+31
-17
lines changed

setup.cfg

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,21 @@ universal=1
44
[metadata]
55
description-file=README.rst
66
license_file = LICENSE
7+
8+
[flake8]
9+
# References:
10+
# https://flake8.readthedocs.io/en/latest/user/configuration.html
11+
# https://flake8.readthedocs.io/en/latest/user/error-codes.html
12+
exclude = __init__.py
13+
ignore =
14+
# Import formatting
15+
E4,
16+
# Comparing types instead of isinstance
17+
E721,
18+
# Assigning lambda expression
19+
E731,
20+
# Ambiguous variable names
21+
E741,
22+
# Allow breaks after binary operators
23+
W504
24+
max-line-length = 120

tests/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
22
try:
3-
from unittest2 import TestCase
3+
from unittest2 import TestCase # NOQA
44
except ImportError:
5-
from unittest import TestCase
5+
from unittest import TestCase # NOQA

tests/test_application_master.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ def test_task_attempt(self, request_mock):
6161

6262
def test_task_attempt_counters(self, request_mock):
6363
self.app.task_attempt_counters('app_1', 'job_2', 'task_3', 'attempt_4')
64-
request_mock.assert_called_with('/proxy/app_1/ws/v1/mapreduce/jobs/job_2/tasks/task_3/attempt/attempt_4/counters')
64+
request_mock.assert_called_with(
65+
'/proxy/app_1/ws/v1/mapreduce/jobs/job_2/tasks/task_3/attempt/attempt_4/counters')

tests/test_base.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# -*- coding: utf-8 -*-
22
try:
3-
from httplib import OK
3+
from httplib import OK # NOQA
44
except ImportError:
5-
from http.client import OK
5+
from http.client import OK # NOQA
66

77
import json
8-
import requests
98
import requests_mock
109

1110
from tests import TestCase
@@ -17,7 +16,7 @@ class BaseYarnAPITestCase(TestCase):
1716
@staticmethod
1817
def success_response():
1918
return {
20-
'status':'success'
19+
'status': 'success'
2120
}
2221

2322
def test_valid_request(self):
@@ -30,7 +29,6 @@ def test_valid_request(self):
3029
assert requests_get_mock.called
3130
self.assertIn(response.data['status'], 'success')
3231

33-
3432
def test_valid_request_with_parameters(self):
3533
with requests_mock.mock() as requests_get_mock:
3634
requests_get_mock.get('/ololo?foo=bar', text=json.dumps(BaseYarnAPITestCase.success_response()))

tests/test_hadoop_conf.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
_http_getresponse_method = ''
1313

1414
try:
15-
from httplib import HTTPConnection, OK, NOT_FOUND
15+
from httplib import HTTPConnection, OK, NOT_FOUND # NOQA
1616
_http_request_method = 'httplib.HTTPConnection.request'
1717
_http_getresponse_method = 'httplib.HTTPConnection.getresponse'
1818
except ImportError:
19-
from http.client import HTTPConnection, OK, NOT_FOUND
19+
from http.client import HTTPConnection, OK, NOT_FOUND # NOQA
2020
_http_request_method = 'http.client.HTTPConnection.request'
2121
_http_getresponse_method = 'http.client.HTTPConnection.getresponse'
2222

@@ -118,10 +118,10 @@ def getheader(self, header_key, default_return):
118118
http_getresponse_mock.return_value = ResponseMock(OK, {})
119119
self.assertTrue(hadoop_conf._check_is_active_rm('example2', '8022'))
120120
http_getresponse_mock.reset_mock()
121-
http_getresponse_mock.return_value = ResponseMock(OK, {'Refresh':"testing"})
121+
http_getresponse_mock.return_value = ResponseMock(OK, {'Refresh': "testing"})
122122
self.assertFalse(hadoop_conf._check_is_active_rm('example2', '8022'))
123123
http_getresponse_mock.reset_mock()
124-
http_getresponse_mock.return_value = ResponseMock(NOT_FOUND, {'Refresh':"testing"})
124+
http_getresponse_mock.return_value = ResponseMock(NOT_FOUND, {'Refresh': "testing"})
125125
self.assertFalse(hadoop_conf._check_is_active_rm('example2', '8022'))
126126
http_conn_request_mock.side_effect = Exception('error')
127127
http_conn_request_mock.reset_mock()
@@ -136,14 +136,12 @@ def test_get_resource_manager(self):
136136
host_port = hadoop_conf._get_resource_manager(hadoop_conf.CONF_DIR, None)
137137

138138
self.assertEqual(('example.com', '8022'), host_port)
139-
parse_mock.assert_called_with('/etc/hadoop/conf/yarn-site.xml',
140-
'yarn.resourcemanager.webapp.address')
139+
parse_mock.assert_called_with('/etc/hadoop/conf/yarn-site.xml', 'yarn.resourcemanager.webapp.address')
141140

142141
host_port = hadoop_conf._get_resource_manager(hadoop_conf.CONF_DIR, 'rm1')
143142

144143
self.assertEqual(('example.com', '8022'), host_port)
145-
parse_mock.assert_called_with('/etc/hadoop/conf/yarn-site.xml',
146-
'yarn.resourcemanager.webapp.address.rm1')
144+
parse_mock.assert_called_with('/etc/hadoop/conf/yarn-site.xml', 'yarn.resourcemanager.webapp.address.rm1')
147145

148146
parse_mock.reset_mock()
149147
parse_mock.return_value = None

tests/test_main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
from mock import patch, PropertyMock
32
from tests import TestCase
43

54
import yarn_api_client.main as m

0 commit comments

Comments
 (0)