Skip to content

Commit 0c3b765

Browse files
committed
Format files with ruff
1 parent a398c80 commit 0c3b765

File tree

5 files changed

+12
-20
lines changed

5 files changed

+12
-20
lines changed

src/pyotp/contrib/steam.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ class Steam(TOTP):
1313
"""
1414

1515
def __init__(
16-
self,
17-
s: str,
18-
name: Optional[str] = None,
19-
issuer: Optional[str] = None,
20-
interval: int = 30,
21-
digits: int = 5
16+
self, s: str, name: Optional[str] = None, issuer: Optional[str] = None, interval: int = 30, digits: int = 5
2217
) -> None:
2318
"""
2419
:param s: secret in base32 format

src/pyotp/hotp.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ def __init__(
2929
"""
3030
if digest is None:
3131
digest = hashlib.sha1
32-
elif digest in [
33-
hashlib.md5,
34-
hashlib.shake_128
35-
]:
32+
elif digest in [hashlib.md5, hashlib.shake_128]:
3633
raise ValueError("selected digest function must generate digest size greater than or equals to 18 bytes")
3734

3835
self.initial_count = initial_count

src/pyotp/otp.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ def __init__(
2121
if digits > 10:
2222
raise ValueError("digits must be no greater than 10")
2323
self.digest = digest
24-
if digest in [
25-
hashlib.md5,
26-
hashlib.shake_128
27-
]:
24+
if digest in [hashlib.md5, hashlib.shake_128]:
2825
raise ValueError("selected digest function must generate digest size greater than or equals to 18 bytes")
2926
self.secret = s
3027
self.name = name or "Secret"

src/pyotp/totp.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ def __init__(
3232
"""
3333
if digest is None:
3434
digest = hashlib.sha1
35-
elif digest in [
36-
hashlib.md5,
37-
hashlib.shake_128
38-
]:
35+
elif digest in [hashlib.md5, hashlib.shake_128]:
3936
raise ValueError("selected digest function must generate digest size greater than or equals to 18 bytes")
4037

4138
self.interval = interval

test.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,16 +334,22 @@ def test_valid_window(self):
334334
self.assertTrue(totp.verify("681610", 200, 1))
335335
self.assertFalse(totp.verify("195979", 200, 1))
336336

337+
337338
class DigestFunctionTest(unittest.TestCase):
338339
def test_md5(self):
339340
with self.assertRaises(ValueError) as cm:
340341
pyotp.OTP(s="secret", digest=hashlib.md5)
341-
self.assertEqual("selected digest function must generate digest size greater than or equals to 18 bytes", str(cm.exception))
342+
self.assertEqual(
343+
"selected digest function must generate digest size greater than or equals to 18 bytes", str(cm.exception)
344+
)
342345

343346
def test_shake128(self):
344347
with self.assertRaises(ValueError) as cm:
345348
pyotp.OTP(s="secret", digest=hashlib.shake_128)
346-
self.assertEqual("selected digest function must generate digest size greater than or equals to 18 bytes", str(cm.exception))
349+
self.assertEqual(
350+
"selected digest function must generate digest size greater than or equals to 18 bytes", str(cm.exception)
351+
)
352+
347353

348354
class ParseUriTest(unittest.TestCase):
349355
def test_invalids(self):

0 commit comments

Comments
 (0)