File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 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]:
4646 @property # type: ignore
4747 @override
4848 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 )
5053 if issubclass (type (proxied ), LazyProxy ):
5154 return type (proxied )
5255 return proxied .__class__
Original file line number Diff line number Diff line change @@ -21,3 +21,14 @@ def test_recursive_proxy() -> None:
2121 assert dir (proxy ) == []
2222 assert type (proxy ).__name__ == "RecursiveLazyProxy"
2323 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