File tree 2 files changed +16
-1
lines changed
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,10 @@ def __dir__(self) -> Iterable[str]:
46
46
@property # type: ignore
47
47
@override
48
48
def __class__ (self ) -> type : # pyright: ignore
49
- proxied = self .__get_proxied__ ()
49
+ try :
50
+ proxied = self .__get_proxied__ ()
51
+ except Exception :
52
+ return type (self )
50
53
if issubclass (type (proxied ), LazyProxy ):
51
54
return type (proxied )
52
55
return proxied .__class__
Original file line number Diff line number Diff line change 3
3
from typing_extensions import override
4
4
5
5
from openai ._utils import LazyProxy
6
+ from openai ._extras ._common import MissingDependencyError
6
7
7
8
8
9
class RecursiveLazyProxy (LazyProxy [Any ]):
@@ -21,3 +22,14 @@ def test_recursive_proxy() -> None:
21
22
assert dir (proxy ) == []
22
23
assert type (proxy ).__name__ == "RecursiveLazyProxy"
23
24
assert type (operator .attrgetter ("name.foo.bar.baz" )(proxy )).__name__ == "RecursiveLazyProxy"
25
+
26
+
27
+ def test_is_instance_with_missing_dependency_error () -> None :
28
+ class MissingDepsProxy (LazyProxy [Any ]):
29
+ @override
30
+ def __load__ (self ) -> Any :
31
+ raise MissingDependencyError ("Mocking missing dependency" )
32
+
33
+ proxy = MissingDepsProxy ()
34
+ assert not isinstance (proxy , dict )
35
+ assert isinstance (proxy , LazyProxy )
You can’t perform that action at this time.
0 commit comments