{"categories":[{"label":"Software Development","url":"https://skillfed.io/packages/category/software-development/6"}],"enrichment":{"capability":"Patchy modifies Python functions at runtime by replacing their code objects with patched versions, using standard unified diff format to specify changes while keeping the function object itself intact.","skillfed_tags":["runtime-patching","testing-utilities","code-modification"],"use_cases":["Apply targeted fixes to external library functions without maintaining a fork or monkey patch","Temporarily modify function behavior in tests using the context manager or decorator form","Replace a function's implementation with a simpler alternative using the `replace()` API","Verify that a function hasn't changed before applying a patch, catching unexpected upstream modifications","Patch methods on classes you don't own, with context validation to detect breaking changes"],"what_it_does":"Patchy lets you modify the behavior of Python functions at runtime by applying unified diff patches to their source code. Instead of monkey-patching or forking a library, you specify exactly what lines should change using standard patch format, and patchy rewrites the function's code object. This is useful when you need to apply small, targeted fixes to external libraries without maintaining a full fork\u2014the patch includes context lines that must match, so you'll catch if the underlying function has changed unexpectedly.\n\nThe package works by extracting the function's source with `inspect.getsource()`, applying the patch via the system `patch` utility, recompiling the modified code, and replacing the function's code object. It handles special cases like instance methods, class methods, and static methods transparently. It also provides a context manager and decorator (`temp_patch`) for temporary patches, and a simpler `replace()` function for cases where you'd rather provide the expected and new source directly instead of writing a diff.","worth_installing":"Yes, if you need to apply small, context-validated patches to functions in external libraries and want better visibility than monkey-patching. The low install friction, active maintenance, no runtime dependencies, and MIT license make it safe to add. However, consider whether a fork, a pull request to the upstream project, or a simpler monkey patch would be more maintainable for your use case\u2014patchy is best for temporary or niche fixes, not as a substitute for proper dependency management."},"id":"patchy","links":{"html":"https://skillfed.io/packages/patchy","md":"https://skillfed.io/packages/patchy.md","pypi":"https://pypi.org/project/patchy/"},"maintenance":{"status":"active"},"meta":{"latest_release":"2025-09-09","license_spdx":"MIT","license_treatment":"permissive","name":"patchy","python_support":"supports_current","summary":"Patch the inner source of python functions at runtime."},"popularity":{"monthly_downloads":894302,"position":4792,"tier":"top_5000"},"security":{"n_vulnerabilities":0},"version":"2.10.0"}
