Skip to main content

Overview

Provides tools for guerilla (monkey)-patching.

The package provides two methods, patch and wrap, that are used to decorate the patch method.

Patching is only allowed if a signature on the original method is provided. Multiple signatures can be provided corresponding to various bona fide versions of the method.

Usage

>>> from monkey import patch, wrap

A patch completely replaces the original method.

>>> @patch(Module.existing_method, *method_signatures)
... def some_patch(*args):
...     pass
>>> Module.existing_method = some_patch

A wrap gets the original method passed as the first argument.

>>> @wrap(Module.existing_method, *method_signatures)
... def some_wrap(func, *args):
...     pass
>>> Module.existing_method = some_wrap

See the inline doctests for more information.

Metadata

Release files for monkey 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for monkey 0.1
File Size Uploaded Provenance Actions
monkey-0.1.tar.gz 2.6 kB Without provenance Details for monkey-0.1.tar.gz

Release files / monkey-0.1.tar.gz

Download URL monkey-0.1.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
549761aac2a1af46b6470efcb0023b3ca5449c854f97d7ac26edbd748a2d66e8
BLAKE2b-256 checksum
How to use checksums
6fe4bf774e5a7511763bb06cd30beeabbd2ad3235b62f0197a404f59e9044fc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for monkey 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page