Monkey patching utilities for classes
Project description
class-interference
Monkey patching utilities for classes.
Installation
pip install class-interference
Usage example
from class_interference import Extension, inject, apply_extensions
class LibraryClass:
def library_method(self, *args, **kwargs):
return None
class LibraryClassExtension(LibraryClass, Extension):
@inject
def library_method(self, *args, **kwargs):
original_value = self.super_ext.library_method(*args, **kwargs)
if original_value is None:
raise ValueError
return original_value
apply_extensions(LibraryClassExtension)
if __name__ == "__main__":
library_class_instance = LibraryClass()
library_class_instance.library_method() # raises ValueError
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file class_interference-1.1.1.tar.gz.
File metadata
- Download URL: class_interference-1.1.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.6 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f63f6241cd541b2203ebc4628e174d822ae5775ac366b44bd3312d76f88ae62
|
|
| MD5 |
7f9589358fdde33c1714fbfe65f7376a
|
|
| BLAKE2b-256 |
af0662e0edaceb1c0607bc2e65ef3633344793fbbafaef5ea0ce7dabca4356a9
|
File details
Details for the file class_interference-1.1.1-py3-none-any.whl.
File metadata
- Download URL: class_interference-1.1.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.6 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd7281747a58efcb1c767f5b41befe55dc8f30c309d9cca43fb4ea8545994c11
|
|
| MD5 |
f21dd8c974dc7e753354ff7658a00b1e
|
|
| BLAKE2b-256 |
f63377886184f51772555b86c336b7f7c7ca9ff39be98569126c789ccde8b731
|