wrapt 2.0.0


pip install wrapt

  Latest version

Released: Oct 19, 2025


Meta
Author: Graham Dumpleton
Requires Python: >=3.8

Classifiers

Development Status
  • 5 - Production/Stable

Programming Language
  • Python :: 3
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14
  • Python :: Implementation :: CPython
  • Python :: Implementation :: PyPy

wrapt

PyPI Documentation License

A Python module for decorators, wrappers and monkey patching.

Overview

The wrapt module provides a transparent object proxy for Python, which can be used as the basis for the construction of function wrappers and decorator functions.

The wrapt module focuses very much on correctness. It goes way beyond existing mechanisms such as functools.wraps() to ensure that decorators preserve introspectability, signatures, type checking abilities etc. The decorators that can be constructed using this module will work in far more scenarios than typical decorators and provide more predictable and consistent behaviour.

To ensure that the overhead is as minimal as possible, a C extension module is used for performance critical components. An automatic fallback to a pure Python implementation is also provided where a target system does not have a compiler to allow the C extension to be compiled.

Features

  • Universal decorators that work with functions, methods, classmethods, staticmethods, and classes
  • Transparent object proxies for advanced wrapping scenarios
  • Monkey patching utilities for safe runtime modifications
  • C extension for optimal performance with Python fallback
  • Comprehensive introspection preservation (signatures, annotations, etc.)
  • Thread-safe decorator implementations

Installation

pip install wrapt

Quick Start

Basic Decorator

import wrapt

@wrapt.decorator
def pass_through(wrapped, instance, args, kwargs):
    return wrapped(*args, **kwargs)

@pass_through
def function():
    pass

Decorator with Arguments

import wrapt

def with_arguments(myarg1, myarg2):
    @wrapt.decorator
    def wrapper(wrapped, instance, args, kwargs):
        print(f"Arguments: {myarg1}, {myarg2}")
        return wrapped(*args, **kwargs)
    return wrapper

@with_arguments(1, 2)
def function():
    pass

Universal Decorator

import inspect
import wrapt

@wrapt.decorator
def universal(wrapped, instance, args, kwargs):
    if instance is None:
        if inspect.isclass(wrapped):
            # Decorator was applied to a class
            print("Decorating a class")
        else:
            # Decorator was applied to a function or staticmethod
            print("Decorating a function")
    else:
        if inspect.isclass(instance):
            # Decorator was applied to a classmethod
            print("Decorating a classmethod")
        else:
            # Decorator was applied to an instancemethod
            print("Decorating an instance method")
    
    return wrapped(*args, **kwargs)

Documentation

For comprehensive documentation, examples, and advanced usage patterns, visit:

wrapt.readthedocs.io

Supported Python Versions

  • Python 3.8+
  • CPython
  • PyPy

Contributing

We welcome contributions! This is a pretty casual process - if you're interested in suggesting changes, improvements, or have found a bug, please reach out via the GitHub issue tracker. Whether it's a small fix, new feature idea, or just a question about how something works, feel free to start a discussion.

Please note that wrapt is now considered a mature project. We're not expecting any significant new developments or major feature additions. The primary focus is on ensuring that the package continues to work correctly with newer Python versions and maintaining compatibility as the Python ecosystem evolves.

Testing

For information about running tests, including Python version-specific test conventions and available test commands, see TESTING.md.

License

This project is licensed under the BSD License - see the LICENSE file for details.

Links

Related Blog Posts

This repository also contains a series of blog posts explaining the design and implementation of wrapt:

2.0.0 Oct 19, 2025
2.0.0rc6 Oct 17, 2025
2.0.0rc5 Oct 16, 2025
2.0.0rc4 Oct 05, 2025
2.0.0rc3 Oct 03, 2025
2.0.0rc2 Aug 19, 2025
2.0.0rc1 Aug 11, 2025
1.17.3 Aug 12, 2025
1.17.2 Jan 14, 2025
1.17.1 Jan 11, 2025
1.17.0 Nov 22, 2024
1.17.0rc1 Oct 17, 2024
1.17.0.dev4 Oct 07, 2024
1.17.0.dev3 Oct 06, 2024
1.16.0 Nov 09, 2023
1.16.0rc2 Nov 05, 2023
1.16.0rc1 Oct 07, 2023
1.15.0 Feb 27, 2023
1.15.0rc1 Jan 12, 2023
1.14.2 Aug 12, 2025
1.14.1 May 02, 2022
1.14.0 Mar 10, 2022
1.14.0rc1 Mar 05, 2022
1.13.3 Oct 29, 2021
1.13.3rc2 Oct 23, 2021
1.13.3rc1 Oct 17, 2021
1.13.2 Oct 13, 2021
1.13.2rc1 Oct 11, 2021
1.13.1 Oct 05, 2021
1.13.0 Oct 04, 2021
1.13.0rc3 Aug 17, 2021
1.13.0rc2 Aug 06, 2021
1.13.0rc1 Aug 06, 2021
1.12.1 Mar 09, 2020
1.12.0 Feb 16, 2020
1.11.2 Jun 18, 2019
1.11.1 Jan 19, 2019
1.11.0 Jan 10, 2019
1.10.11 Aug 11, 2017
1.10.10 Mar 15, 2017
1.10.9 Mar 15, 2017
1.10.8 Apr 10, 2016
1.10.7 Mar 31, 2016
1.10.6 Dec 08, 2015
1.10.5 Jul 03, 2015
1.10.4 Mar 18, 2015
1.10.2 Dec 11, 2014
1.10.1 Nov 26, 2014
1.10.0 Nov 20, 2014
1.9.0 Aug 22, 2014
1.8.0 May 03, 2014
1.7.0 Apr 26, 2014
1.6.0 Jan 26, 2014
1.5.1 Jan 14, 2014
1.5.0 Jan 02, 2014
1.4.2 Dec 28, 2013
1.4.1 Dec 23, 2013
1.4.0 Dec 20, 2013
1.3.1 Dec 19, 2013
1.3.0 Dec 19, 2013
1.2.1 Oct 16, 2013
1.2.0 Oct 11, 2013
1.1.4 Sep 27, 2013
1.1.3 Sep 24, 2013
1.1.2 Sep 20, 2013
1.1.1 Sep 19, 2013
1.1.0 Sep 18, 2013
1.0.0 Sep 06, 2013

Wheel compatibility matrix

Platform CPython 3.8 CPython 3.9 CPython 3.10 CPython 3.11 CPython 3.12 CPython 3.13 CPython 3.14 CPython (additional flags: t) 3.13 CPython (additional flags: t) 3.14 Python 3
any
macosx_10_13_universal2
macosx_10_13_x86_64
macosx_10_9_universal2
macosx_10_9_x86_64
macosx_11_0_arm64
manylinux1_x86_64
manylinux2014_aarch64
manylinux_2_17_aarch64
manylinux_2_28_aarch64
manylinux_2_28_x86_64
manylinux_2_31_riscv64
manylinux_2_39_riscv64
manylinux_2_5_x86_64
musllinux_1_2_aarch64
musllinux_1_2_riscv64
musllinux_1_2_x86_64
win32
win_amd64
win_arm64

Files in release

wrapt-2.0.0-cp310-cp310-macosx_10_9_universal2.whl (75.6KiB)
wrapt-2.0.0-cp310-cp310-macosx_10_9_x86_64.whl (59.2KiB)
wrapt-2.0.0-cp310-cp310-macosx_11_0_arm64.whl (60.1KiB)
wrapt-2.0.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (111.0KiB)
wrapt-2.0.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (112.9KiB)
wrapt-2.0.0-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl (109.4KiB)
wrapt-2.0.0-cp310-cp310-musllinux_1_2_aarch64.whl (112.1KiB)
wrapt-2.0.0-cp310-cp310-musllinux_1_2_riscv64.whl (108.6KiB)
wrapt-2.0.0-cp310-cp310-musllinux_1_2_x86_64.whl (110.7KiB)
wrapt-2.0.0-cp310-cp310-win32.whl (56.6KiB)
wrapt-2.0.0-cp310-cp310-win_amd64.whl (58.9KiB)
wrapt-2.0.0-cp310-cp310-win_arm64.whl (57.4KiB)
wrapt-2.0.0-cp311-cp311-macosx_10_9_universal2.whl (75.6KiB)
wrapt-2.0.0-cp311-cp311-macosx_10_9_x86_64.whl (59.2KiB)
wrapt-2.0.0-cp311-cp311-macosx_11_0_arm64.whl (60.1KiB)
wrapt-2.0.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (111.4KiB)
wrapt-2.0.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (113.4KiB)
wrapt-2.0.0-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl (109.9KiB)
wrapt-2.0.0-cp311-cp311-musllinux_1_2_aarch64.whl (112.7KiB)
wrapt-2.0.0-cp311-cp311-musllinux_1_2_riscv64.whl (109.1KiB)
wrapt-2.0.0-cp311-cp311-musllinux_1_2_x86_64.whl (111.1KiB)
wrapt-2.0.0-cp311-cp311-win32.whl (56.6KiB)
wrapt-2.0.0-cp311-cp311-win_amd64.whl (58.9KiB)
wrapt-2.0.0-cp311-cp311-win_arm64.whl (57.4KiB)
wrapt-2.0.0-cp312-cp312-macosx_10_13_universal2.whl (76.2KiB)
wrapt-2.0.0-cp312-cp312-macosx_10_13_x86_64.whl (59.7KiB)
wrapt-2.0.0-cp312-cp312-macosx_11_0_arm64.whl (60.2KiB)
wrapt-2.0.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (118.6KiB)
wrapt-2.0.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (120.1KiB)
wrapt-2.0.0-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl (114.6KiB)
wrapt-2.0.0-cp312-cp312-musllinux_1_2_aarch64.whl (118.6KiB)
wrapt-2.0.0-cp312-cp312-musllinux_1_2_riscv64.whl (113.5KiB)
wrapt-2.0.0-cp312-cp312-musllinux_1_2_x86_64.whl (117.7KiB)
wrapt-2.0.0-cp312-cp312-win32.whl (56.8KiB)
wrapt-2.0.0-cp312-cp312-win_amd64.whl (59.0KiB)
wrapt-2.0.0-cp312-cp312-win_arm64.whl (57.5KiB)
wrapt-2.0.0-cp313-cp313-macosx_10_13_universal2.whl (76.3KiB)
wrapt-2.0.0-cp313-cp313-macosx_10_13_x86_64.whl (59.7KiB)
wrapt-2.0.0-cp313-cp313-macosx_11_0_arm64.whl (60.2KiB)
wrapt-2.0.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (118.6KiB)
wrapt-2.0.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (120.2KiB)
wrapt-2.0.0-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl (114.6KiB)
wrapt-2.0.0-cp313-cp313-musllinux_1_2_aarch64.whl (118.6KiB)
wrapt-2.0.0-cp313-cp313-musllinux_1_2_riscv64.whl (113.6KiB)
wrapt-2.0.0-cp313-cp313-musllinux_1_2_x86_64.whl (117.8KiB)
wrapt-2.0.0-cp313-cp313-win32.whl (56.8KiB)
wrapt-2.0.0-cp313-cp313-win_amd64.whl (59.0KiB)
wrapt-2.0.0-cp313-cp313-win_arm64.whl (57.5KiB)
wrapt-2.0.0-cp313-cp313t-macosx_10_13_universal2.whl (80.1KiB)
wrapt-2.0.0-cp313-cp313t-macosx_10_13_x86_64.whl (61.4KiB)
wrapt-2.0.0-cp313-cp313t-macosx_11_0_arm64.whl (62.1KiB)
wrapt-2.0.0-cp313-cp313t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (149.1KiB)
wrapt-2.0.0-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (155.1KiB)
wrapt-2.0.0-cp313-cp313t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl (142.6KiB)
wrapt-2.0.0-cp313-cp313t-musllinux_1_2_aarch64.whl (152.0KiB)
wrapt-2.0.0-cp313-cp313t-musllinux_1_2_riscv64.whl (141.0KiB)
wrapt-2.0.0-cp313-cp313t-musllinux_1_2_x86_64.whl (146.8KiB)
wrapt-2.0.0-cp313-cp313t-win32.whl (58.5KiB)
wrapt-2.0.0-cp313-cp313t-win_amd64.whl (61.7KiB)
wrapt-2.0.0-cp313-cp313t-win_arm64.whl (58.9KiB)
wrapt-2.0.0-cp314-cp314-macosx_10_13_universal2.whl (76.4KiB)
wrapt-2.0.0-cp314-cp314-macosx_10_13_x86_64.whl (59.8KiB)
wrapt-2.0.0-cp314-cp314-macosx_11_0_arm64.whl (60.3KiB)
wrapt-2.0.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (117.6KiB)
wrapt-2.0.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (119.9KiB)
wrapt-2.0.0-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl (114.6KiB)
wrapt-2.0.0-cp314-cp314-musllinux_1_2_aarch64.whl (118.4KiB)
wrapt-2.0.0-cp314-cp314-musllinux_1_2_riscv64.whl (113.6KiB)
wrapt-2.0.0-cp314-cp314-musllinux_1_2_x86_64.whl (116.8KiB)
wrapt-2.0.0-cp314-cp314-win32.whl (57.3KiB)
wrapt-2.0.0-cp314-cp314-win_amd64.whl (59.5KiB)
wrapt-2.0.0-cp314-cp314-win_arm64.whl (57.9KiB)
wrapt-2.0.0-cp314-cp314t-macosx_10_13_universal2.whl (80.1KiB)
wrapt-2.0.0-cp314-cp314t-macosx_10_13_x86_64.whl (61.4KiB)
wrapt-2.0.0-cp314-cp314t-macosx_11_0_arm64.whl (62.1KiB)
wrapt-2.0.0-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (149.1KiB)
wrapt-2.0.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (155.1KiB)
wrapt-2.0.0-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl (142.7KiB)
wrapt-2.0.0-cp314-cp314t-musllinux_1_2_aarch64.whl (152.0KiB)
wrapt-2.0.0-cp314-cp314t-musllinux_1_2_riscv64.whl (141.0KiB)
wrapt-2.0.0-cp314-cp314t-musllinux_1_2_x86_64.whl (146.8KiB)
wrapt-2.0.0-cp314-cp314t-win32.whl (59.1KiB)
wrapt-2.0.0-cp314-cp314t-win_amd64.whl (62.5KiB)
wrapt-2.0.0-cp314-cp314t-win_arm64.whl (59.2KiB)
wrapt-2.0.0-cp38-cp38-macosx_10_9_universal2.whl (75.3KiB)
wrapt-2.0.0-cp38-cp38-macosx_10_9_x86_64.whl (59.0KiB)
wrapt-2.0.0-cp38-cp38-macosx_11_0_arm64.whl (59.8KiB)
wrapt-2.0.0-cp38-cp38-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (115.7KiB)
wrapt-2.0.0-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (118.1KiB)
wrapt-2.0.0-cp38-cp38-musllinux_1_2_aarch64.whl (116.1KiB)
wrapt-2.0.0-cp38-cp38-musllinux_1_2_x86_64.whl (114.4KiB)
wrapt-2.0.0-cp38-cp38-win32.whl (56.5KiB)
wrapt-2.0.0-cp38-cp38-win_amd64.whl (58.8KiB)
wrapt-2.0.0-cp39-cp39-macosx_10_9_universal2.whl (75.6KiB)
wrapt-2.0.0-cp39-cp39-macosx_10_9_x86_64.whl (59.2KiB)
wrapt-2.0.0-cp39-cp39-macosx_11_0_arm64.whl (60.1KiB)
wrapt-2.0.0-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (110.7KiB)
wrapt-2.0.0-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (112.6KiB)
wrapt-2.0.0-cp39-cp39-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl (109.1KiB)
wrapt-2.0.0-cp39-cp39-musllinux_1_2_aarch64.whl (111.8KiB)
wrapt-2.0.0-cp39-cp39-musllinux_1_2_riscv64.whl (108.4KiB)
wrapt-2.0.0-cp39-cp39-musllinux_1_2_x86_64.whl (110.5KiB)
wrapt-2.0.0-cp39-cp39-win32.whl (56.6KiB)
wrapt-2.0.0-cp39-cp39-win_amd64.whl (58.9KiB)
wrapt-2.0.0-cp39-cp39-win_arm64.whl (57.4KiB)
wrapt-2.0.0-py3-none-any.whl (43.0KiB)
wrapt-2.0.0.tar.gz (79.8KiB)
Extras:
Dependencies: