{"id":21056215,"url":"https://github.com/christophercrouzet/gorilla","last_synced_at":"2026-03-14T10:11:05.549Z","repository":{"id":18039612,"uuid":"21082957","full_name":"christophercrouzet/gorilla","owner":"christophercrouzet","description":"Convenient approach to monkey patching.","archived":false,"fork":false,"pushed_at":"2021-04-17T00:09:21.000Z","size":179,"stargazers_count":62,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-14T12:04:16.625Z","etag":null,"topics":["gorilla","monkey-patching","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/christophercrouzet.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-22T01:37:07.000Z","updated_at":"2025-01-08T13:52:26.000Z","dependencies_parsed_at":"2022-08-08T14:00:34.417Z","dependency_job_id":null,"html_url":"https://github.com/christophercrouzet/gorilla","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophercrouzet%2Fgorilla","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophercrouzet%2Fgorilla/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophercrouzet%2Fgorilla/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophercrouzet%2Fgorilla/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christophercrouzet","download_url":"https://codeload.github.com/christophercrouzet/gorilla/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442427,"owners_count":22071864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gorilla","monkey-patching","python"],"created_at":"2024-11-19T16:49:27.118Z","updated_at":"2026-03-14T10:11:05.503Z","avatar_url":"https://github.com/christophercrouzet.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Gorilla\n=======\n\n.. image:: https://img.shields.io/travis/christophercrouzet/gorilla/master.svg\n   :target: https://travis-ci.org/christophercrouzet/gorilla\n   :alt: Build status\n\n.. image:: https://img.shields.io/coveralls/christophercrouzet/gorilla/master.svg\n   :target: https://coveralls.io/r/christophercrouzet/gorilla\n   :alt: Coverage Status\n\n.. image:: https://img.shields.io/pypi/v/gorilla.svg\n   :target: https://pypi.python.org/pypi/gorilla\n   :alt: PyPI latest version\n\n.. image:: https://readthedocs.org/projects/gorilla/badge/?version=latest\n   :target: https://gorilla.readthedocs.io\n   :alt: Documentation status\n\n.. image:: https://img.shields.io/pypi/l/gorilla.svg\n   :target: https://pypi.python.org/pypi/gorilla\n   :alt: License\n\n\nGorilla is a Python library that provides a convenient approach to monkey\npatching.\n\nMonkey patching is the process of **modifying module and class attributes at\nruntime** with the purpose of replacing or extending third-party code.\n\nAlthough *not* a recommended practice, it is sometimes useful to fix or modify\nthe behaviour of a piece of code from a third-party library, or to extend its\npublic interface while making the additions feel like they are built-in into\nthe library.\n\nThe Python language makes monkey patching extremely easy but the advantages of\nGorilla are multiple, not only in assuring a **consistent behaviour** on both\nPython 2 and Python 3 versions, but also in preventing common source of errors,\nand making the process both **intuitive and convenient** even when faced with\n*large* numbers of patches to create.\n\n\nFeatures\n--------\n\n* intuitive and convenient decorator approach to create patches.\n* can create patches for all class or module members at once.\n* compatible with both Python 2 and Python 3.\n* customizable behaviour.\n\n\nUsage\n-----\n\nThanks to the dynamic nature of Python that makes monkey patching possible, the\nprocess happens at runtime without ever having to directly modify the source\ncode of the third-party library:\n\n.. code-block:: python\n\n   \u003e\u003e\u003e import gorilla\n   \u003e\u003e\u003e import destination\n   \u003e\u003e\u003e @gorilla.patches(destination.Class)\n   ... class MyClass(object):\n   ...     def method(self):\n   ...         print(\"Hello\")\n   ...     @classmethod\n   ...     def class_method(cls):\n   ...         print(\"world!\")\n\n\nThe code above creates two patches, one for each member of the class\n``MyClass``, but does not apply them yet. In other words, they define the\ninformation required to carry on the operation but are not yet inserted into\nthe specified destination class ``destination.Class``.\n\nSuch patches created with the decorators can then be automatically retrieved by\nrecursively scanning a package or a module, then applied:\n\n.. code-block:: python\n\n   \u003e\u003e\u003e import gorilla\n   \u003e\u003e\u003e import mypackage\n   \u003e\u003e\u003e patches = gorilla.find_patches([mypackage])\n   \u003e\u003e\u003e for patch in patches:\n   ...     gorilla.apply(patch)\n\n\nSee the `Tutorial`_ section from the documentation for more detailed examples\nand explanations on how to use Gorilla.\n\n\nDocumentation\n-------------\n\nRead the documentation online at `gorilla.readthedocs.io`_ or check its source\nin the ``doc`` directory.\n\n\nOut There\n---------\n\nProjects using Gorilla include:\n\n* `bana \u003chttps://github.com/christophercrouzet/bana\u003e`_\n* `mlflow \u003chttps://github.com/mlflow/mlflow\u003e`_\n\n\nAuthor\n------\n\nChristopher Crouzet\n\u003c`christophercrouzet.com \u003chttps://christophercrouzet.com\u003e`_\u003e\n\n\n.. _gorilla.readthedocs.io: https://gorilla.readthedocs.io\n.. _Tutorial: https://gorilla.readthedocs.io/en/latest/tutorial.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristophercrouzet%2Fgorilla","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristophercrouzet%2Fgorilla","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristophercrouzet%2Fgorilla/lists"}