About
python-monkey-business is a package that provides a decorator for monkey-patching python functions at runtime.
Installation
Using pip:
pip install python-monkey-business
Or, to install from source:
pip install -e git+https://github.com/theatlantic/python-monkey-business.git#egg=python-monkey-business
If the source is already checked out, use setuptools:
python setup.py develop
Usage
To use python-monkey-business to swap out a function in a class or module at runtime:
import monkeybiz
from foomodule import FooClass
import barmodule
# This replaces FooClass.bar with our method
@monkeybiz.patch(FooClass)
def bar(original_fn, *args, **kwargs):
print "Patched!"
return original_fn(*args, **kwargs)
# This replaces barmodule.baz with our function
@monkeybiz.patch(barmodule)
def baz(original_fn, *args, **kwargs):
#...
The first argument to monkeybiz.patch can be either a module, a class, or a list of modules and/or classes. The decorator also takes optional name and avoid_doublewrap keyword arguments. If name is omitted, the name of the function being patched will be the name of the function being decorated. If avoid_doublewrap is True (the default), then functions and methods can only be patched once using this function.
Use monkeybiz.unpatch() to revert a monkey-patched function to its original.
License
This code is licensed under the Simplified BSD License. View the LICENSE file under the root directory for complete license and copyright information.
Metadata
Release files for python-monkey-business 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| python-monkey-business-1.1.0.tar.gz | 4.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_monkey_business-1.1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 8.9 kB
Release files / python-monkey-business-1.1.0.tar.gz
| Download URL | python-monkey-business-1.1.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8393839cc741415ed5ddc2bd58e2d4ce07f966a7d26b7aebff19dcec64818edc
|
|
BLAKE2b-256 checksum How to use checksums |
21bca6182bb30701d0df25ad336f2dd74343447032e0995025ba82079a94f745
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Release files / python_monkey_business-1.1.0-py2.py3-none-any.whl
| Download URL | python_monkey_business-1.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
15b4f603c749ba9a7b4f1acd36af023a6c5ba0f7e591c945f8253f0ef44bf389
|
|
BLAKE2b-256 checksum How to use checksums |
43a2b6a5cbd5822b4d049adfedf496ce0908480e5a41722fda7b7ffaacb086d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Security for python-monkey-business 1.1.0
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.