8000 Update __exit__ type · faif/python-patterns@a11ecbd · GitHub
[go: up one dir, main page]

Skip to content

Commit a11ecbd

Browse files
author
Roy, Debakar
committed
Update __exit__ type
1 parent e3d7d8a commit a11ecbd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

patterns/creational/pool.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
Stores a set of initialized objects kept ready to use.
2929
"""
3030
from queue import Queue
31+
from types import TracebackType
32+
from typing import Union
3133

3234

3335
class ObjectPool:
@@ -40,7 +42,12 @@ def __enter__(self) -> str:
4042
self.item = self._queue.get()
4143
return self.item
4244

43-
def __exit__(self, Type: None, value: None, traceback: None) -> None:
45+
def __exit__(
46+
self,
47+
Type: Union[type[BaseException], None],
48+
value: Union[BaseException, None],
49+
traceback: Union[TracebackType, None],
50+
) -> None:
4451
if self.item is not None:
4552
self._queue.put(self.item)
4653
self.item = None

0 commit comments

Comments
 (0)
0