File tree 3 files changed +4
-24
lines changed
3 files changed +4
-24
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
3
from typing import TYPE_CHECKING , Any
4
- from typing_extensions import ClassVar , override
4
+ from typing_extensions import override
5
5
6
6
from .._utils import LazyProxy
7
7
from ._common import MissingDependencyError , format_instructions
14
14
15
15
16
16
class NumpyProxy (LazyProxy [Any ]):
17
- should_cache : ClassVar [bool ] = True
18
-
19
17
@override
20
18
def __load__ (self ) -> Any :
21
19
try :
Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
3
from typing import TYPE_CHECKING , Any
4
- from typing_extensions import ClassVar , override
4
+ from typing_extensions import override
5
5
6
6
from .._utils import LazyProxy
7
7
from ._common import MissingDependencyError , format_instructions
14
14
15
15
16
16
class PandasProxy (LazyProxy [Any ]):
17
- should_cache : ClassVar [bool ] = True
18
-
19
17
@override
20
18
def __load__ (self ) -> Any :
21
19
try :
Original file line number Diff line number Diff line change 2
2
3
3
from abc import ABC , abstractmethod
4
4
from typing import Generic , TypeVar , Iterable , cast
5
- from typing_extensions import ClassVar , override
5
+ from typing_extensions import override
6
6
7
7
T = TypeVar ("T" )
8
8
@@ -13,11 +13,6 @@ class LazyProxy(Generic[T], ABC):
13
13
This includes forwarding attribute access and othe methods.
14
14
"""
15
15
16
- should_cache : ClassVar [bool ] = False
17
-
18
- def __init__ (self ) -> None :
19
- self .__proxied : T | None = None
20
-
21
16
# Note: we have to special case proxies that themselves return proxies
22
17
# to support using a proxy as a catch-all for any random access, e.g. `proxy.foo.bar.baz`
23
18
@@ -57,18 +52,7 @@ def __class__(self) -> type:
57
52
return proxied .__class__
58
53
59
54
def __get_proxied__ (self ) -> T :
60
- if not self .should_cache :
61
- return self .__load__ ()
62
-
63
- proxied = self .__proxied
64
- if proxied is not None :
65
- return proxied
66
-
67
- self .__proxied = proxied = self .__load__ ()
68
- return proxied
69
-
70
- def __set_proxied__ (self , value : T ) -> None :
71
- self .__proxied = value
55
+ return self .__load__ ()
72
56
73
57
def __as_proxied__ (self ) -> T :
74
58
"""Helper method that returns the current proxy, typed as the loaded object"""
You can’t perform that action at this time.
0 commit comments