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 (
25 ObjectProxy as BaseObjectProxy, # type: ignore[no-redef,import-not-found]
26 )
27 from ._wrappers import ( # type: ignore[no-redef,import-not-found]
28 PartialCallableObjectProxy,
29 _FunctionWrapperBase,
30 )
32 _using_c_extension = True
33 except ImportError:
34 # C extensions not available, using Python implementations
35 pass
38def partial(*args, **kwargs):
39 """Create a callable object proxy with partial application of the given
40 arguments and keywords. This behaves the same as `functools.partial`, but
41 implemented using the `ObjectProxy` class to provide better support for
42 introspection.
43 """
44 return PartialCallableObjectProxy(*args, **kwargs)