File tree 2 files changed +15
-1
lines changed
2 files changed +15
-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 @@ -21,3 +21,14 @@ def test_recursive_proxy() -> None:
21
21
assert dir (proxy ) == []
22
22
assert type (proxy ).__name__ == "RecursiveLazyProxy"
23
23
assert type (operator .attrgetter ("name.foo.bar.baz" )(proxy )).__name__ == "RecursiveLazyProxy"
24
+
25
+
26
+ def test_isinstance_does_not_error () -> None :
27
+ class AlwaysErrorProxy (LazyProxy [Any ]):
28
+ @override
29
+ def __load__ (self ) -> Any :
30
+ raise RuntimeError ("Mocking missing dependency" )
31
+
32
+ proxy = AlwaysErrorProxy ()
33
+ assert not isinstance (proxy , dict )
34
+ assert isinstance (proxy , LazyProxy )
You can’t perform that action at this time.
0 commit comments