Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/wrapt/__wrapt__.py: 82%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""This module is used to switch between C and Python implementations of the
2wrappers.
3"""
5import os
7from .wrappers import BoundFunctionWrapper, CallableObjectProxy, FunctionWrapper
8from .wrappers import ObjectProxy as BaseObjectProxy
9from .wrappers import PartialCallableObjectProxy, _FunctionWrapperBase
11# Try to use C extensions if not disabled.
13_using_c_extension = False
15_use_extensions = not os.environ.get("WRAPT_DISABLE_EXTENSIONS")
17if _use_extensions:
18 try:
19 from ._wrappers import ( # type: ignore[no-redef,import-not-found]
20 BoundFunctionWrapper,
21 CallableObjectProxy,
22 FunctionWrapper,
23 )
24 from ._wrappers import ObjectProxy as BaseObjectProxy # type: ignore[no-redef]
25 from ._wrappers import ( # type: ignore[no-redef,import-not-found]
26 PartialCallableObjectProxy,
27 _FunctionWrapperBase,
28 )
30 _using_c_extension = True
31 except ImportError:
32 # C extensions not available, using Python implementations
33 pass
36def partial(*args, **kwargs):
37 """Create a callable object proxy with partial application of the given
38 arguments and keywords. This behaves the same as `functools.partial`, but
39 implemented using the `ObjectProxy` class to provide better support for
40 introspection.
41 """
42 return PartialCallableObjectProxy(*args, **kwargs)