{"id":29656530,"url":"https://github.com/zincware/supercharge","last_synced_at":"2025-07-22T08:35:57.891Z","repository":{"id":45159186,"uuid":"444057580","full_name":"zincware/supercharge","owner":"zincware","description":"Expand Python Super Capabilities","archived":false,"fork":false,"pushed_at":"2022-01-04T16:42:36.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-13T23:05:55.158Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zincware.png","metadata":{"files":{"readme":"README.rst","changelog":null,"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":"2022-01-03T12:43:38.000Z","updated_at":"2024-09-20T14:51:50.000Z","dependencies_parsed_at":"2022-08-27T19:40:22.841Z","dependency_job_id":null,"html_url":"https://github.com/zincware/supercharge","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/zincware/supercharge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zincware%2Fsupercharge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zincware%2Fsupercharge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zincware%2Fsupercharge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zincware%2Fsupercharge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zincware","download_url":"https://codeload.github.com/zincware/supercharge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zincware%2Fsupercharge/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266456402,"owners_count":23931404,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-07-22T08:35:50.577Z","updated_at":"2025-07-22T08:35:57.870Z","avatar_url":"https://github.com/zincware.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"|build| |license| |code style| |coverage| |colab-badge|\n\nSupercharge\n-----------\n\nThis package allows you to automatically run code before and after a given class method.\nFurthermore, this behaviour can be enforced on child classes as well.\n\nSupercharge is available via:\n\n.. code-block::\n\n    pip install supercharge\n\nExample\n=======\n\n.. code-block:: py\n\n    from supercharge import Charge\n\n    class HelloWorld:\n        def __init__(self):\n            self.run_prepared = False\n            self.run_state = False\n\n        @Charge\n        def run(self):\n            if self.run_prepared:\n                print(\"running ...\")\n\n        @run.enter\n        def pre_run(self):\n            self.run_prepared = True\n\n        @run.exit\n        def post_run(self):\n            self.run_state = True\n\n\nIf this is behaviour is desired in subclassed runs one must use the `Base` class.\n\n.. code-block:: py\n\n    from supercharge import Charge, Base\n\n    class HelloWorld(Base):\n        def __init__(self):\n            self.run_prepared = False\n            self.run_state = False\n\n        @Charge\n        def run(self):\n            raise NotImplementedError\n\n        @run.enter\n        def pre_run(self):\n            self.run_prepared = True\n\n        @run.exit\n        def post_run(self):\n            self.run_state = True\n\n    class Child(HelloWorld):\n        def run(self):\n            if self.run_prepared:\n                print(\"running ...\")\n\nNoticeable Alternatives\n=======================\nUsing supercharge might not always be the best way to go. In many scenarios an easier way\nto achieve a similar functionality can be\n\n.. code-block:: py\n\n    class HelloWorld:\n        def __init__(self):\n            self.run_prepared = False\n            self.run_state = False\n\n        def run(self):\n            self.pre_run()\n            self.base_run()\n            self.post_run()\n\n        def base_run(self):\n            raise NotImplementedError\n\n        def pre_run(self):\n            self.run_prepared = True\n\n        def post_run(self):\n            self.run_state = True\n\n    class Child(HelloWorld):\n        def base_run(self):\n            if self.run_prepared:\n                print(\"running ...\")\n\nwhere you call `Child.run()` and overwrite `Child.base_run()`.\n\n\n.. badges\n\n.. |build| image:: https://github.com/zincware/supercharge/actions/workflows/pytest.yaml/badge.svg\n    :alt: Build tests passing\n    :target: https://github.com/zincware/py-test/blob/readme_badges/\n\n\n.. |license| image:: https://img.shields.io/badge/License-EPL-purple.svg?style=flat\n    :alt: Project license\n    :target: https://www.eclipse.org/legal/epl-2.0/faq.php\n\n.. |code style| image:: https://img.shields.io/badge/code%20style-black-black\n    :alt: Code style: black\n    :target: https://github.com/psf/black/\n    \n.. |coverage| image:: https://coveralls.io/repos/github/zincware/supercharge/badge.svg\n    :alt: Code coverage\n    :target: https://coveralls.io/github/zincware/supercharge\n\n.. |colab-badge| image:: https://colab.research.google.com/assets/colab-badge.svg\n    :alt: Open Example in Google Colab\n    :target: https://colab.research.google.com/github/zincware/supercharge/blob/main/examples/introduction.ipynb\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzincware%2Fsupercharge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzincware%2Fsupercharge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzincware%2Fsupercharge/lists"}