Skip to content

Commit dbfef14

Browse files
committed
Use dataclass
1 parent d93c243 commit dbfef14

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

totp.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
"""
55
import hmac
66
import time
7+
from dataclasses import dataclass
78

89

10+
@dataclass
911
class OTPGenerator:
1012
"""
1113
See https://datatracker.ietf.org/doc/html/rfc2104
1214
See https://datatracker.ietf.org/doc/html/rfc4226
1315
See https://datatracker.ietf.org/doc/html/rfc6238
1416
"""
15-
16-
def __init__(self, key: bytes, *, time_step=30, digits=6, digest='sha1'):
17-
self.key = key
18-
self.time_step = time_step
19-
self.digits = digits
20-
self.digest = digest
17+
key: bytes
18+
time_step: int = 30
19+
digits: int = 6
20+
digest: str = 'sha1'
2121

2222
@classmethod
2323
def from_b32(cls, b32: str, **kwargs):

0 commit comments

Comments
 (0)