We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f04e751 commit 0fd67d8Copy full SHA for 0fd67d8
tests/utils.py
@@ -4,21 +4,22 @@
4
5
6
class SequenceGenerator:
7
- _instance = None
8
- _lock = Lock()
+ _instance: SequenceGenerator | None = None
+ _lock: Lock = Lock()
9
+ _counter: int
10
- def __init__(self):
11
- self._counter = 1
+ def __init__(self) -> None:
12
+ if not hasattr(self, "_counter"):
13
+ self._counter = 1
14
- def __new__(cls):
15
+ def __new__(cls) -> SequenceGenerator:
16
if cls._instance is None:
17
with cls._lock:
18
19
cls._instance = super().__new__(cls)
- cls._instance._counter = 1
20
return cls._instance
21
- def next(self):
22
+ def next(self) -> int:
23
with self._lock:
24
current = self._counter
25
self._counter += 1
0 commit comments