Skip to content

Commit e2209c9

Browse files
committed
Black everything
1 parent 488c93f commit e2209c9

35 files changed

+998
-1098
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
matrix:
1717
PYTHON:
1818
- {VERSION: "3.9", TOXENV: "pep8,packaging,docs", COVERAGE: "false"}
19-
- {VERSION: "pypy2", TOXENV: "pypy-nocoverage", COVERAGE: "false"}
2019
- {VERSION: "pypy3", TOXENV: "pypy3-nocoverage", COVERAGE: "false"}
2120
- {VERSION: "3.9", TOXENV: "py39", OPENSSL: {TYPE: "openssl", VERSION: "1.1.0l"}}
2221
- {VERSION: "3.9", TOXENV: "py39", OPENSSL: {TYPE: "openssl", VERSION: "1.1.1h"}}

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
@@ -77,7 +77,7 @@
7777
where="src", exclude=["_cffi_src", "_cffi_src.*"]
7878
),
7979
include_package_data=True,
80-
python_requires=(">=3.6"),
80+
python_requires=">=3.6",
8181
install_requires=setup_requirements,
8282
setup_requires=setup_requirements,
8383
extras_require={

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
@@ -1165,7 +1165,7 @@ def _create_x509_extension(self, handlers, extension):
11651165
*[
11661166
encode_der(INTEGER, encode_der_integer(x.value))
11671167
for x in extension.value
1168-
]
1168+
],
11691169
)
11701170
value = _encode_asn1_str_gc(self, asn1)
11711171
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
@@ -86,9 +86,7 @@ def public_key(self, backend=None):
8686

8787
class DHParameterNumbers(object):
8888
def __init__(self, p, g, q=None):
89-
if not isinstance(p, int) or not isinstance(
90-
g, int
91-
):
89+
if not isinstance(p, int) or not isinstance(g, int):
9290
raise TypeError("p and g must be integers")
9391
if q is not None and not isinstance(q, int):
9492
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: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
from __future__ import absolute_import, division, print_function
66

77
import abc
8-
9-
try:
10-
# Only available in math in 3.5+
11-
from math import gcd
12-
except ImportError:
13-
from fractions import gcd
8+
from math import gcd
149

1510
from cryptography import utils
1611
from cryptography.exceptions import UnsupportedAlgorithm, _Reasons
@@ -338,9 +333,7 @@ def __hash__(self):
338333

339334
class RSAPublicNumbers(object):
340335
def __init__(self, e, n):
341-
if not isinstance(e, int) or not isinstance(
342-
n, int
343-
):
336+
if not isinstance(e, int) or not isinstance(n, int):
344337
raise TypeError("RSAPublicNumbers arguments must be integers.")
345338

346339
self._e = e

src/cryptography/hazmat/primitives/serialization/ssh.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import os
99
import re
1010
import struct
11+
from base64 import encodebytes as _base64_encode
1112

1213
from cryptography import utils
1314
from cryptography.exceptions import UnsupportedAlgorithm
@@ -32,11 +33,6 @@ def _bcrypt_kdf(*args, **kwargs):
3233
raise UnsupportedAlgorithm("Need bcrypt module")
3334

3435

35-
try:
36-
from base64 import encodebytes as _base64_encode
37-
except ImportError:
38-
from base64 import encodestring as _base64_encode
39-
4036
_SSH_ED25519 = b"ssh-ed25519"
4137
_SSH_RSA = b"ssh-rsa"
4238
_SSH_DSA = b"ssh-dss"

src/cryptography/utils.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from __future__ import absolute_import, division, print_function
66

77
import abc
8-
import binascii
98
import inspect
109
import sys
1110
import warnings
@@ -72,12 +71,6 @@ class InterfaceNotImplemented(Exception):
7271
pass
7372

7473

75-
if hasattr(inspect, "signature"):
76-
signature = inspect.signature
77-
else:
78-
signature = inspect.getargspec
79-
80-
8174
def verify_interface(iface, klass):
8275
for method in iface.__abstractmethods__:
8376
if not hasattr(klass, method):
@@ -87,8 +80,8 @@ def verify_interface(iface, klass):
8780
if isinstance(getattr(iface, method), abc.abstractproperty):
8881
# Can't properly verify these yet.
8982
continue
90-
sig = signature(getattr(iface, method))
91-
actual = signature(getattr(klass, method))
83+
sig = inspect.signature(getattr(iface, method))
84+
actual = inspect.signature(getattr(klass, method))
9285
if sig != actual:
9386
raise InterfaceNotImplemented(
9487
"{}.{}'s signature differs from the expected. Expected: "

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):
@@ -94,7 +94,7 @@ def test_invalid_key_size(self):
9494

9595
def test_invalid_key_type(self):
9696
with pytest.raises(TypeError, match="key must be bytes"):
97-
Camellia(u"0" * 32)
97+
Camellia("0" * 32)
9898

9999

100100
class TestTripleDES(object):
@@ -109,7 +109,7 @@ def test_invalid_key_size(self):
109109

110110
def test_invalid_key_type(self):
111111
with pytest.raises(TypeError, match="key must be bytes"):
112-
TripleDES(u"0" * 16)
112+
TripleDES("0" * 16)
113113

114114

115115
class TestBlowfish(object):
@@ -127,7 +127,7 @@ def test_invalid_key_size(self):
127127

128128
def test_invalid_key_type(self):
129129
with pytest.raises(TypeError, match="key must be bytes"):
130-
Blowfish(u"0" * 8)
130+
Blowfish("0" * 8)
131131

132132

133133
class TestCAST5(object):
@@ -145,7 +145,7 @@ def test_invalid_key_size(self):
145145

146146
def test_invalid_key_type(self):
147147
with pytest.raises(TypeError, match="key must be bytes"):
148-
CAST5(u"0" * 10)
148+
CAST5("0" * 10)
149149

150150

151151
class TestARC4(object):
@@ -171,7 +171,7 @@ def test_invalid_key_size(self):
171171

172172
def test_invalid_key_type(self):
173173
with pytest.raises(TypeError, match="key must be bytes"):
174-
ARC4(u"0" * 10)
174+
ARC4("0" * 10)
175175

176176

177177
class TestIDEA(object):
@@ -185,7 +185,7 @@ def test_invalid_key_size(self):
185185

186186
def test_invalid_key_type(self):
187187
with pytest.raises(TypeError, match="key must be bytes"):
188-
IDEA(u"0" * 16)
188+
IDEA("0" * 16)
189189

190190

191191
class TestSEED(object):
@@ -199,7 +199,7 @@ def test_invalid_key_size(self):
199199

200200
def test_invalid_key_type(self):
201201
with pytest.raises(TypeError, match="key must be bytes"):
202-
SEED(u"0" * 16)
202+
SEED("0" * 16)
203203

204204

205205
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():

0 commit comments

Comments
 (0)