Skip to content

Commit bf45f44

Browse files
committed
feat: add generic in SingleInstanceMetaClass
1 parent 6625af7 commit bf45f44

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pymilvus/orm/connections.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import pathlib
1616
import threading
1717
import time
18-
from typing import Callable, Tuple, Union
18+
from typing import Callable, Generic, Tuple, TypeVar, Union
1919
from urllib import parse
2020

2121
from pymilvus.client.check import is_legal_address, is_legal_host, is_legal_port
@@ -31,6 +31,8 @@
3131

3232
VIRTUAL_PORT = 443
3333

34+
T = TypeVar("T")
35+
3436

3537
def synchronized(func: Callable):
3638
"""
@@ -45,13 +47,13 @@ def lock_func(*args, **kwargs):
4547
return lock_func
4648

4749

48-
class SingleInstanceMetaClass(type):
50+
class SingleInstanceMetaClass(Generic[T]):
4951
instance = None
5052

5153
def __init__(cls, *args, **kwargs) -> None:
5254
super().__init__(*args, **kwargs)
5355

54-
def __call__(cls, *args, **kwargs):
56+
def __call__(cls, *args, **kwargs) -> T:
5557
if cls.instance:
5658
return cls.instance
5759
cls.instance = cls.__new__(cls)

0 commit comments

Comments
 (0)