Skip to content

Commit faf7247

Browse files
committed
Black everything
1 parent b5c7cf7 commit faf7247

33 files changed

+994
-1078
lines changed

.travis/upload_coverage.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ if [ -n "${TOXENV}" ]; then
77
case "${TOXENV}" in
88
pypy3-nocoverage);;
99
pep8);;
10-
py3pep8);;
1110
docs);;
1211
*)
1312
source ~/.venv/bin/activate

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
base_dir = os.path.join(os.path.dirname(__file__), os.pardir)
8282
about = {}
8383
with open(os.path.join(base_dir, "src", "cryptography", "__about__.py")) as f:
84-
exec (f.read(), about)
84+
exec(f.read(), about)
8585

8686
version = release = about["__version__"]
8787

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
about = {}
3535
with open(os.path.join(src_dir, "cryptography", "__about__.py")) as f:
36-
exec (f.read(), about)
36+
exec(f.read(), about)
3737

3838

3939
# `setup_requirements` must be kept in sync with `pyproject.toml`

src/_cffi_src/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
base_src = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1717
about = {}
1818
with open(os.path.join(base_src, "cryptography", "__about__.py")) as f:
19-
exec (f.read(), about)
19+
exec(f.read(), about)
2020

2121

2222
def build_ffi_for_binding(

src/cryptography/hazmat/backends/openssl/backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ def _create_x509_extension(self, handlers, extension):
11641164
*[
11651165
encode_der(INTEGER, encode_der_integer(x.value))
11661166
for x in extension.value
1167-
]
1167+
],
11681168
)
11691169
value = _encode_asn1_str_gc(self, asn1)
11701170
return self._create_raw_x509_extension(extension, value)

src/cryptography/hazmat/backends/openssl/decode_asn1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def _decode_general_name(backend, gn):
130130
if "1" in bits[prefix:]:
131131
raise ValueError("Invalid netmask")
132132

133-
ip = ipaddress.ip_network(base.exploded + u"/{}".format(prefix))
133+
ip = ipaddress.ip_network(base.exploded + "/{}".format(prefix))
134134
else:
135135
ip = ipaddress.ip_address(data)
136136

src/cryptography/hazmat/primitives/asymmetric/dh.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ def public_key(self, backend=None):
8383

8484
class DHParameterNumbers(object):
8585
def __init__(self, p, g, q=None):
86-
if not isinstance(p, int) or not isinstance(
87-
g, int
88-
):
86+
if not isinstance(p, int) or not isinstance(g, int):
8987
raise TypeError("p and g must be integers")
9088
if q is not None and not isinstance(q, int):
9189
raise TypeError("q must be integer or None")

src/cryptography/hazmat/primitives/asymmetric/ec.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ def sign(self, data, signature_algorithm):
9595
"""
9696

9797

98-
class EllipticCurvePrivateKeyWithSerialization(EllipticCurvePrivateKey, metaclass=abc.ABCMeta):
98+
class EllipticCurvePrivateKeyWithSerialization(
99+
EllipticCurvePrivateKey, metaclass=abc.ABCMeta
100+
):
99101
@abc.abstractmethod
100102
def private_numbers(self):
101103
"""
@@ -335,9 +337,7 @@ def derive_private_key(private_value, curve, backend=None):
335337

336338
class EllipticCurvePublicNumbers(object):
337339
def __init__(self, x, y, curve):
338-
if not isinstance(x, int) or not isinstance(
339-
y, int
340-
):
340+
if not isinstance(x, int) or not isinstance(y, int):
341341
raise TypeError("x and y must be integers.")
342342

343343
if not isinstance(curve, EllipticCurve):

src/cryptography/hazmat/primitives/asymmetric/rsa.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,7 @@ def __hash__(self):
338338

339339
class RSAPublicNumbers(object):
340340
def __init__(self, e, n):
341-
if not isinstance(e, int) or not isinstance(
342-
n, int
343-
):
341+
if not isinstance(e, int) or not isinstance(n, int):
344342
raise TypeError("RSAPublicNumbers arguments must be integers.")
345343

346344
self._e = e

src/cryptography/x509/extensions.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,9 @@ def __init__(self, require_explicit_policy, inhibit_policy_mapping):
668668

669669
def __repr__(self):
670670
return (
671-
u"<PolicyConstraints(require_explicit_policy={0.require_explicit"
672-
u"_policy}, inhibit_policy_mapping={0.inhibit_policy_"
673-
u"mapping})>".format(self)
671+
"<PolicyConstraints(require_explicit_policy={0.require_explicit"
672+
"_policy}, inhibit_policy_mapping={0.inhibit_policy_"
673+
"mapping})>".format(self)
674674
)
675675

676676
def __eq__(self, other):
@@ -740,8 +740,7 @@ def __init__(self, policy_identifier, policy_qualifiers):
740740
if policy_qualifiers:
741741
policy_qualifiers = list(policy_qualifiers)
742742
if not all(
743-
isinstance(x, (str, UserNotice))
744-
for x in policy_qualifiers
743+
isinstance(x, (str, UserNotice)) for x in policy_qualifiers
745744
):
746745
raise TypeError(
747746
"policy_qualifiers must be a list of strings and/or "
@@ -1177,8 +1176,8 @@ def _validate_ip_name(self, tree):
11771176

11781177
def __repr__(self):
11791178
return (
1180-
u"<NameConstraints(permitted_subtrees={0.permitted_subtrees}, "
1181-
u"excluded_subtrees={0.excluded_subtrees})>".format(self)
1179+
"<NameConstraints(permitted_subtrees={0.permitted_subtrees}, "
1180+
"excluded_subtrees={0.excluded_subtrees})>".format(self)
11821181
)
11831182

11841183
def __hash__(self):

tests/hazmat/backends/test_openssl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@
3939

4040

4141
def skip_if_libre_ssl(openssl_version):
42-
if u"LibreSSL" in openssl_version:
42+
if "LibreSSL" in openssl_version:
4343
pytest.skip("LibreSSL hard-codes RAND_bytes to use arc4random.")
4444

4545

4646
class TestLibreSkip(object):
4747
def test_skip_no(self):
48-
assert skip_if_libre_ssl(u"OpenSSL 1.0.2h 3 May 2016") is None
48+
assert skip_if_libre_ssl("OpenSSL 1.0.2h 3 May 2016") is None
4949

5050
def test_skip_yes(self):
5151
with pytest.raises(pytest.skip.Exception):
52-
skip_if_libre_ssl(u"LibreSSL 2.1.6")
52+
skip_if_libre_ssl("LibreSSL 2.1.6")
5353

5454

5555
class DummyMGF(object):

tests/hazmat/primitives/test_chacha20.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ def test_invalid_nonce(self):
7171

7272
def test_invalid_key_type(self):
7373
with pytest.raises(TypeError, match="key must be bytes"):
74-
algorithms.ChaCha20(u"0" * 32, b"0" * 16)
74+
algorithms.ChaCha20("0" * 32, b"0" * 16)

tests/hazmat/primitives/test_ciphers.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_invalid_key_size(self):
4646

4747
def test_invalid_key_type(self):
4848
with pytest.raises(TypeError, match="key must be bytes"):
49-
AES(u"0" * 32)
49+
AES("0" * 32)
5050

5151

5252
class TestAESXTS(object):
@@ -87,7 +87,7 @@ def test_invalid_key_size(self):
8787

8888
def test_invalid_key_type(self):
8989
with pytest.raises(TypeError, match="key must be bytes"):
90-
Camellia(u"0" * 32)
90+
Camellia("0" * 32)
9191

9292

9393
class TestTripleDES(object):
@@ -102,7 +102,7 @@ def test_invalid_key_size(self):
102102

103103
def test_invalid_key_type(self):
104104
with pytest.raises(TypeError, match="key must be bytes"):
105-
TripleDES(u"0" * 16)
105+
TripleDES("0" * 16)
106106

107107

108108
class TestBlowfish(object):
@@ -120,7 +120,7 @@ def test_invalid_key_size(self):
120120

121121
def test_invalid_key_type(self):
122122
with pytest.raises(TypeError, match="key must be bytes"):
123-
Blowfish(u"0" * 8)
123+
Blowfish("0" * 8)
124124

125125

126126
class TestCAST5(object):
@@ -138,7 +138,7 @@ def test_invalid_key_size(self):
138138

139139
def test_invalid_key_type(self):
140140
with pytest.raises(TypeError, match="key must be bytes"):
141-
CAST5(u"0" * 10)
141+
CAST5("0" * 10)
142142

143143

144144
class TestARC4(object):
@@ -164,7 +164,7 @@ def test_invalid_key_size(self):
164164

165165
def test_invalid_key_type(self):
166166
with pytest.raises(TypeError, match="key must be bytes"):
167-
ARC4(u"0" * 10)
167+
ARC4("0" * 10)
168168

169169

170170
class TestIDEA(object):
@@ -178,7 +178,7 @@ def test_invalid_key_size(self):
178178

179179
def test_invalid_key_type(self):
180180
with pytest.raises(TypeError, match="key must be bytes"):
181-
IDEA(u"0" * 16)
181+
IDEA("0" * 16)
182182

183183

184184
class TestSEED(object):
@@ -192,7 +192,7 @@ def test_invalid_key_size(self):
192192

193193
def test_invalid_key_type(self):
194194
with pytest.raises(TypeError, match="key must be bytes"):
195-
SEED(u"0" * 16)
195+
SEED("0" * 16)
196196

197197

198198
def test_invalid_backend():

tests/hazmat/primitives/test_cmac.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ def test_verify_reject_unicode(self, backend):
182182
cmac = CMAC(AES(key), backend)
183183

184184
with pytest.raises(TypeError):
185-
cmac.update(u"")
185+
cmac.update("")
186186

187187
with pytest.raises(TypeError):
188-
cmac.verify(u"")
188+
cmac.verify("")
189189

190190
@pytest.mark.supported(
191191
only_if=lambda backend: backend.cmac_algorithm_supported(

tests/hazmat/primitives/test_concatkdf.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,29 +100,29 @@ def test_invalid_verify(self, backend):
100100
def test_unicode_typeerror(self, backend):
101101
with pytest.raises(TypeError):
102102
ConcatKDFHash(
103-
hashes.SHA256(), 16, otherinfo=u"foo", backend=backend
103+
hashes.SHA256(), 16, otherinfo="foo", backend=backend
104104
)
105105

106106
with pytest.raises(TypeError):
107107
ckdf = ConcatKDFHash(
108108
hashes.SHA256(), 16, otherinfo=None, backend=backend
109109
)
110110

111-
ckdf.derive(u"foo")
111+
ckdf.derive("foo")
112112

113113
with pytest.raises(TypeError):
114114
ckdf = ConcatKDFHash(
115115
hashes.SHA256(), 16, otherinfo=None, backend=backend
116116
)
117117

118-
ckdf.verify(u"foo", b"bar")
118+
ckdf.verify("foo", b"bar")
119119

120120
with pytest.raises(TypeError):
121121
ckdf = ConcatKDFHash(
122122
hashes.SHA256(), 16, otherinfo=None, backend=backend
123123
)
124124

125-
ckdf.verify(b"foo", u"bar")
125+
ckdf.verify(b"foo", "bar")
126126

127127

128128
@pytest.mark.requires_backend_interface(interface=HMACBackend)
@@ -249,7 +249,7 @@ def test_unicode_typeerror(self, backend):
249249
ConcatKDFHMAC(
250250
hashes.SHA256(),
251251
16,
252-
salt=u"foo",
252+
salt="foo",
253253
otherinfo=None,
254254
backend=backend,
255255
)
@@ -259,7 +259,7 @@ def test_unicode_typeerror(self, backend):
259259
hashes.SHA256(),
260260
16,
261261
salt=None,
262-
otherinfo=u"foo",
262+
otherinfo="foo",
263263
backend=backend,
264264
)
265265

@@ -268,21 +268,21 @@ def test_unicode_typeerror(self, backend):
268268
hashes.SHA256(), 16, salt=None, otherinfo=None, backend=backend
269269
)
270270

271-
ckdf.derive(u"foo")
271+
ckdf.derive("foo")
272272

273273
with pytest.raises(TypeError):
274274
ckdf = ConcatKDFHMAC(
275275
hashes.SHA256(), 16, salt=None, otherinfo=None, backend=backend
276276
)
277277

278-
ckdf.verify(u"foo", b"bar")
278+
ckdf.verify("foo", b"bar")
279279

280280
with pytest.raises(TypeError):
281281
ckdf = ConcatKDFHMAC(
282282
hashes.SHA256(), 16, salt=None, otherinfo=None, backend=backend
283283
)
284284

285-
ckdf.verify(b"foo", u"bar")
285+
ckdf.verify(b"foo", "bar")
286286

287287

288288
def test_invalid_backend():

tests/hazmat/primitives/test_constant_time.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
class TestConstantTimeBytesEq(object):
1313
def test_reject_unicode(self):
1414
with pytest.raises(TypeError):
15-
constant_time.bytes_eq(b"foo", u"foo")
15+
constant_time.bytes_eq(b"foo", "foo")
1616

1717
with pytest.raises(TypeError):
18-
constant_time.bytes_eq(u"foo", b"foo")
18+
constant_time.bytes_eq("foo", b"foo")
1919

2020
with pytest.raises(TypeError):
21-
constant_time.bytes_eq(u"foo", u"foo")
21+
constant_time.bytes_eq("foo", "foo")
2222

2323
def test_compares(self):
2424
assert constant_time.bytes_eq(b"foo", b"foo") is True

tests/hazmat/primitives/test_hashes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class TestHashContext(object):
2222
def test_hash_reject_unicode(self, backend):
2323
m = hashes.Hash(hashes.SHA1(), backend=backend)
2424
with pytest.raises(TypeError):
25-
m.update(u"\u00FC")
25+
m.update("\u00FC")
2626

2727
def test_hash_algorithm_instance(self, backend):
2828
with pytest.raises(TypeError):

tests/hazmat/primitives/test_hkdf.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,31 +65,31 @@ def test_verify_invalid(self, backend):
6565

6666
def test_unicode_typeerror(self, backend):
6767
with pytest.raises(TypeError):
68-
HKDF(hashes.SHA256(), 16, salt=u"foo", info=None, backend=backend)
68+
HKDF(hashes.SHA256(), 16, salt="foo", info=None, backend=backend)
6969

7070
with pytest.raises(TypeError):
71-
HKDF(hashes.SHA256(), 16, salt=None, info=u"foo", backend=backend)
71+
HKDF(hashes.SHA256(), 16, salt=None, info="foo", backend=backend)
7272

7373
with pytest.raises(TypeError):
7474
hkdf = HKDF(
7575
hashes.SHA256(), 16, salt=None, info=None, backend=backend
7676
)
7777

78-
hkdf.derive(u"foo")
78+
hkdf.derive("foo")
7979

8080
with pytest.raises(TypeError):
8181
hkdf = HKDF(
8282
hashes.SHA256(), 16, salt=None, info=None, backend=backend
8383
)
8484

85-
hkdf.verify(u"foo", b"bar")
85+
hkdf.verify("foo", b"bar")
8686

8787
with pytest.raises(TypeError):
8888
hkdf = HKDF(
8989
hashes.SHA256(), 16, salt=None, info=None, backend=backend
9090
)
9191

92-
hkdf.verify(b"foo", u"bar")
92+
hkdf.verify(b"foo", "bar")
9393

9494
def test_derive_short_output(self, backend):
9595
hkdf = HKDF(hashes.SHA256(), 4, salt=None, info=None, backend=backend)
@@ -202,7 +202,7 @@ def test_unicode_error(self, backend):
202202
hkdf = HKDFExpand(hashes.SHA256(), 42, info, backend)
203203

204204
with pytest.raises(TypeError):
205-
hkdf.derive(u"first")
205+
hkdf.derive("first")
206206

207207

208208
def test_invalid_backend():

0 commit comments

Comments
 (0)