wrapt 2.0.0rc2__cp39-cp39-musllinux_1_2_x86_64.whl → 2.0.1rc1__cp39-cp39-musllinux_1_2_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of wrapt might be problematic. Click here for more details.

wrapt/__init__.py CHANGED
@@ -2,14 +2,14 @@
2
2
  Wrapt is a library for decorators, wrappers and monkey patching.
3
3
  """
4
4
 
5
- __version_info__ = ("2", "0", "0", "rc2")
5
+ __version_info__ = ("2", "0", "1", "rc1")
6
6
  __version__ = ".".join(__version_info__)
7
7
 
8
8
  from .__wrapt__ import (
9
+ BaseObjectProxy,
9
10
  BoundFunctionWrapper,
10
11
  CallableObjectProxy,
11
12
  FunctionWrapper,
12
- ObjectProxy,
13
13
  PartialCallableObjectProxy,
14
14
  partial,
15
15
  )
@@ -30,12 +30,16 @@ from .patches import (
30
30
  wrap_object,
31
31
  wrap_object_attribute,
32
32
  )
33
+ from .proxies import AutoObjectProxy, LazyObjectProxy, ObjectProxy, lazy_import
33
34
  from .weakrefs import WeakFunctionProxy
34
35
 
35
36
  __all__ = (
37
+ "AutoObjectProxy",
38
+ "BaseObjectProxy",
36
39
  "BoundFunctionWrapper",
37
40
  "CallableObjectProxy",
38
41
  "FunctionWrapper",
42
+ "LazyObjectProxy",
39
43
  "ObjectProxy",
40
44
  "PartialCallableObjectProxy",
41
45
  "partial",
@@ -49,6 +53,7 @@ __all__ = (
49
53
  "when_imported",
50
54
  "apply_patch",
51
55
  "function_wrapper",
56
+ "lazy_import",
52
57
  "patch_function_wrapper",
53
58
  "resolve_path",
54
59
  "transient_function_wrapper",
wrapt/__init__.pyi CHANGED
@@ -24,13 +24,33 @@ if sys.version_info >= (3, 10):
24
24
 
25
25
  # ObjectProxy
26
26
 
27
- class ObjectProxy(Generic[T]):
27
+ class BaseObjectProxy(Generic[T]):
28
28
  __wrapped__: T
29
29
  def __init__(self, wrapped: T) -> None: ...
30
30
 
31
+ class ObjectProxy(BaseObjectProxy[T]):
32
+ def __init__(self, wrapped: T) -> None: ...
33
+
34
+ class AutoObjectProxy(BaseObjectProxy[T]):
35
+ def __init__(self, wrapped: T) -> None: ...
36
+
37
+ # LazyObjectProxy
38
+
39
+ class LazyObjectProxy(AutoObjectProxy[T]):
40
+ def __init__(
41
+ self, callback: Callable[[], T] | None, *, interface: Any = ...
42
+ ) -> None: ...
43
+
44
+ @overload
45
+ def lazy_import(name: str) -> LazyObjectProxy[ModuleType]: ...
46
+ @overload
47
+ def lazy_import(
48
+ name: str, attribute: str, *, interface: Any = ...
49
+ ) -> LazyObjectProxy[Any]: ...
50
+
31
51
  # CallableObjectProxy
32
52
 
33
- class CallableObjectProxy(ObjectProxy[T]):
53
+ class CallableObjectProxy(BaseObjectProxy[T]):
34
54
  def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
35
55
 
36
56
  # PartialCallableObjectProxy
@@ -123,7 +143,7 @@ if sys.version_info >= (3, 10):
123
143
  callable: (
124
144
  Callable[P, R]
125
145
  | Callable[Concatenate[type[T], P], R]
126
- # | Callable[Concatenate[Any, P], R] # Don't use, breaks stuff.
146
+ | Callable[Concatenate[Any, P], R]
127
147
  | Callable[[type[T]], R]
128
148
  | Descriptor
129
149
  ),
wrapt/__wrapt__.py CHANGED
@@ -4,20 +4,14 @@ wrappers.
4
4
 
5
5
  import os
6
6
 
7
- from .wrappers import (
8
- BoundFunctionWrapper,
9
- CallableObjectProxy,
10
- FunctionWrapper,
11
- ObjectProxy,
12
- PartialCallableObjectProxy,
13
- _FunctionWrapperBase,
14
- )
15
-
16
- # Import Python fallbacks.
17
-
7
+ from .wrappers import BoundFunctionWrapper, CallableObjectProxy, FunctionWrapper
8
+ from .wrappers import ObjectProxy as BaseObjectProxy
9
+ from .wrappers import PartialCallableObjectProxy, _FunctionWrapperBase
18
10
 
19
11
  # Try to use C extensions if not disabled.
20
12
 
13
+ _using_c_extension = False
14
+
21
15
  _use_extensions = not os.environ.get("WRAPT_DISABLE_EXTENSIONS")
22
16
 
23
17
  if _use_extensions:
@@ -26,16 +20,20 @@ if _use_extensions:
26
20
  BoundFunctionWrapper,
27
21
  CallableObjectProxy,
28
22
  FunctionWrapper,
29
- ObjectProxy,
23
+ )
24
+ from ._wrappers import (
25
+ ObjectProxy as BaseObjectProxy, # type: ignore[no-redef,import-not-found]
26
+ )
27
+ from ._wrappers import ( # type: ignore[no-redef,import-not-found]
30
28
  PartialCallableObjectProxy,
31
29
  _FunctionWrapperBase,
32
30
  )
31
+
32
+ _using_c_extension = True
33
33
  except ImportError:
34
34
  # C extensions not available, using Python implementations
35
35
  pass
36
36
 
37
- # Provide an alias for partial().
38
-
39
37
 
40
38
  def partial(*args, **kwargs):
41
39
  """Create a callable object proxy with partial application of the given