Skip to content

Commit

Permalink
Upgrade add-trailing-comma to v2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Jul 20, 2020
1 parent cc4d7ca commit ba14e23
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
@@ -1,7 +1,7 @@
---
repos:
- repo: git://github.com/asottile/add-trailing-comma
rev: v0.7.1
rev: v2.0.1
hooks:
- id: add-trailing-comma

Expand Down
2 changes: 1 addition & 1 deletion cheroot/errors.py
Expand Up @@ -29,7 +29,7 @@ def plat_specific_errors(*errnames):
depending on the specific platform (OS). This function will return
the list of numeric values for a given list of potential names.
"""
missing_attr = set([None, ])
missing_attr = set([None])
unique_nums = set(getattr(errno, k, None) for k in errnames)
return list(unique_nums - missing_attr)

Expand Down
18 changes: 12 additions & 6 deletions cheroot/server.py
Expand Up @@ -1620,12 +1620,16 @@ def clear_stats(self):
[w['Work Time'](w) for w in s['Worker Threads'].values()], 0,
),
'Read Throughput': lambda s: (not s['Enabled']) and -1 or sum(
[w['Bytes Read'](w) / (w['Work Time'](w) or 1e-6)
for w in s['Worker Threads'].values()], 0,
[
w['Bytes Read'](w) / (w['Work Time'](w) or 1e-6)
for w in s['Worker Threads'].values()
], 0,
),
'Write Throughput': lambda s: (not s['Enabled']) and -1 or sum(
[w['Bytes Written'](w) / (w['Work Time'](w) or 1e-6)
for w in s['Worker Threads'].values()], 0,
[
w['Bytes Written'](w) / (w['Work Time'](w) or 1e-6)
for w in s['Worker Threads'].values()
], 0,
),
'Worker Threads': {},
}
Expand Down Expand Up @@ -2134,7 +2138,9 @@ def get_ssl_adapter_class(name='builtin'):
try:
adapter = getattr(mod, attr_name)
except AttributeError:
raise AttributeError("'%s' object has no attribute '%s'"
% (mod_path, attr_name))
raise AttributeError(
"'%s' object has no attribute '%s'"
% (mod_path, attr_name),
)

return adapter
16 changes: 11 additions & 5 deletions cheroot/test/helper.py
Expand Up @@ -108,8 +108,10 @@ def assertEqualDates(self, dt1, dt2, seconds=None):
else:
diff = dt2 - dt1
if not diff < datetime.timedelta(seconds=seconds):
raise AssertionError('%r and %r are not within %r seconds.' %
(dt1, dt2, seconds))
raise AssertionError(
'%r and %r are not within %r seconds.' %
(dt1, dt2, seconds),
)


class Request:
Expand Down Expand Up @@ -155,9 +157,13 @@ def __call__(self, environ, start_response):
resp.status = '404 Not Found'
else:
output = handler(req, resp)
if (output is not None
and not any(resp.status.startswith(status_code)
for status_code in ('204', '304'))):
if (
output is not None
and not any(
resp.status.startswith(status_code)
for status_code in ('204', '304')
)
):
resp.body = output
try:
resp.headers.setdefault('Content-Length', str(len(output)))
Expand Down
6 changes: 3 additions & 3 deletions cheroot/test/test_cli.py
Expand Up @@ -77,9 +77,9 @@ def main(self):
@pytest.mark.parametrize(
('app_name', 'app_method'),
(
(None, 'application',),
('application', 'application',),
('main', 'main',),
(None, 'application'),
('application', 'application'),
('main', 'main'),
),
)
def test_Aplication_resolve(app_name, app_method, wsgi_app):
Expand Down
12 changes: 8 additions & 4 deletions cheroot/test/test_conn.py
Expand Up @@ -45,8 +45,10 @@ def content():
def upload(req, resp):
"""Process file upload and render thank."""
if not req.environ['REQUEST_METHOD'] == 'POST':
raise AssertionError("'POST' != request.method %r" %
req.environ['REQUEST_METHOD'])
raise AssertionError(
"'POST' != request.method %r" %
req.environ['REQUEST_METHOD'],
)
return "thanks for '%s'" % req.environ['wsgi.input'].read()

def custom_204(req, resp):
Expand Down Expand Up @@ -805,11 +807,13 @@ def test_No_Message_Body(test_client):


@pytest.mark.xfail(
reason=unwrap(trim("""
reason=unwrap(
trim("""
Headers from earlier request leak into the request
line for a subsequent request, resulting in 400
instead of 413. See cherrypy/cheroot#69 for details.
""")),
"""),
),
)
def test_Chunked_Encoding(test_client):
"""Test HTTP uploads with chunked transfer-encoding."""
Expand Down
14 changes: 8 additions & 6 deletions cheroot/test/test_ssl.py
Expand Up @@ -40,7 +40,7 @@
IS_WINDOWS
# pylint: disable=unsupported-membership-test
and b'Microsoft Windows Server 2016 Datacenter' in subprocess.check_output(
('systeminfo', ),
('systeminfo',),
)
)
IS_LIBRESSL_BACKEND = ssl.OPENSSL_VERSION.startswith('LibreSSL')
Expand Down Expand Up @@ -149,7 +149,7 @@ def tls_ca_certificate_pem_path(ca):
def tls_certificate(ca):
"""Provide a leaf certificate via fixture."""
interface, host, port = _get_conn_data(ANY_INTERFACE_IPV4)
return ca.issue_server_cert(ntou(interface), )
return ca.issue_server_cert(ntou(interface))


@pytest.fixture
Expand Down Expand Up @@ -359,7 +359,7 @@ def test_tls_client_auth(
)
if not six.PY2:
if IS_MACOS and IS_PYPY and adapter_type == 'pyopenssl':
expected_substrings = ('tlsv1 alert unknown ca', )
expected_substrings = ('tlsv1 alert unknown ca',)
if (
tls_verify_mode in (
ssl.CERT_REQUIRED,
Expand Down Expand Up @@ -433,7 +433,7 @@ def test_ssl_env(
'idna.core.ulabel',
return_value=ntob('127.0.0.1'),
):
client_cert = ca.issue_cert(ntou('127.0.0.1'),)
client_cert = ca.issue_cert(ntou('127.0.0.1'))

with client_cert.private_key_and_cert_chain_pem.tempfile() as cl_pem:
tls_adapter_cls = get_ssl_adapter_class(name=adapter_type)
Expand Down Expand Up @@ -612,8 +612,10 @@ def test_http_over_https_error(
fqdn = '[{}]'.format(fqdn)

expect_fallback_response_over_plain_http = (
(adapter_type == 'pyopenssl'
and (IS_ABOVE_OPENSSL10 or not six.PY2))
(
adapter_type == 'pyopenssl'
and (IS_ABOVE_OPENSSL10 or not six.PY2)
)
or PY27
) or (
IS_GITHUB_ACTIONS_WORKFLOW
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Expand Up @@ -31,7 +31,7 @@
CONDITIONAL_EXTENSIONS = ()

if IS_SPELLCHECK_BUILD:
CONDITIONAL_EXTENSIONS += ('sphinxcontrib.spelling', )
CONDITIONAL_EXTENSIONS += ('sphinxcontrib.spelling',)


extensions = [
Expand Down
2 changes: 1 addition & 1 deletion docs/scm_tag_titles_ext.py
Expand Up @@ -36,7 +36,7 @@ def _get_scm_timestamp_for(commitish, *, scm=None):

try:
ts = subprocess.check_output(
_SCM_COMMANDS[scm] + (commitish, ),
_SCM_COMMANDS[scm] + (commitish,),
stderr=subprocess.DEVNULL,
text=True,
).strip()
Expand Down

0 comments on commit ba14e23

Please sign in to comment.