jaraco.functools
Provides additional functools in the spirit of Python's standard library's functools. Current version: 4.4.0, released on December 21, 2025. Maintained by Jason R. Coombs. Requires Python 3.9 or higher. Release cadence: approximately every 3-4 months.
Common errors
-
ModuleNotFoundError: No module named 'jaraco.functools'
cause This error typically occurs when the 'jaraco.functools' package is not installed in the Python environment, or if there are issues with package resolution, especially in bundled applications (like those created with py2exe/PyInstaller) or when dealing with namespace packages.fixEnsure the package is installed using pip: `pip install jaraco.functools` or if using a package manager like `pacman`, install `python-jaraco.functools`. For bundled applications, ensure the packaging tool correctly includes all namespace package components. -
ImportError: cannot import name 'splat' from 'jaraco.functools'
cause This specific ImportError arises when a dependent library (such as `setuptools` versions 75.x.x) tries to import the `splat` function, which was introduced in `jaraco.functools` version 4.x.x, but an older version of `jaraco.functools` (e.g., prior to 4.x.x) is installed in the environment.fixUpgrade `jaraco.functools` to version 4.x.x or newer to include the `splat` function: `pip install --upgrade jaraco.functools`. -
AttributeError: 'function' object has no attribute 'cache_clear'
cause This error occurs when attempting to call `cache_clear()` on a method decorated with `jaraco.functools.method_cache` before that method has been invoked at least once on an instance, meaning the cache mechanism hasn't been initialized or attached to the instance yet.fixEnsure the decorated method has been called at least once on the instance before attempting to clear its cache. For example: `my_instance.my_method(); my_instance.my_method.cache_clear()`. -
TypeError: 'CacheDescriptor' object is not callable
cause This error occurs when the `@property` decorator is applied to a method that is also decorated with `jaraco.functools.method_cache`. This combination can lead to a conflict because both are descriptors, and `@property` does not chain the descriptor protocol correctly with `method_cache` in older versions.fixAvoid using `@property` directly on methods decorated with `method_cache`. If caching a property's value is needed, consider implementing the caching logic within the property's getter method manually or upgrading to a version of `jaraco.functools` (or Python) where this interaction is resolved or better supported. For current versions of `jaraco.functools`, `method_cache` is designed to work with methods, not properties directly.
Warnings
- breaking FunctionType was moved from jaraco.functools to jaraco.types in version 4.0.0.
- deprecated The 'deprecated_function' is scheduled for removal in version 5.0.0.
Install
-
pip install jaraco.functools
Imports
- FunctionType
from jaraco.functools import FunctionType
Quickstart
from jaraco.functools import FunctionType
# Example usage of FunctionType
def example_function():
pass
print(isinstance(example_function, FunctionType)) # Output: True