{"id":19921491,"url":"https://github.com/pyapp-kit/in-n-out","last_synced_at":"2025-04-30T18:46:36.040Z","repository":{"id":40603316,"uuid":"507722147","full_name":"pyapp-kit/in-n-out","owner":"pyapp-kit","description":"Type-hint-based Python dependency injection you can taste","archived":false,"fork":false,"pushed_at":"2024-12-22T02:57:05.000Z","size":244,"stargazers_count":12,"open_issues_count":7,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-25T00:28:31.253Z","etag":null,"topics":["dependency-injection","python","type-hints","typing"],"latest_commit_sha":null,"homepage":"https://ino.rtfd.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyapp-kit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-27T01:06:04.000Z","updated_at":"2024-11-25T01:52:50.000Z","dependencies_parsed_at":"2023-10-01T03:30:18.908Z","dependency_job_id":"75ccc59f-e0c5-44c9-98b3-8f8e3c6847c2","html_url":"https://github.com/pyapp-kit/in-n-out","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyapp-kit%2Fin-n-out","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyapp-kit%2Fin-n-out/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyapp-kit%2Fin-n-out/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyapp-kit%2Fin-n-out/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyapp-kit","download_url":"https://codeload.github.com/pyapp-kit/in-n-out/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231391234,"owners_count":18369723,"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":["dependency-injection","python","type-hints","typing"],"created_at":"2024-11-12T22:07:45.258Z","updated_at":"2024-12-26T18:10:55.649Z","avatar_url":"https://github.com/pyapp-kit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# in-n-out\n\n[![License](https://img.shields.io/pypi/l/in-n-out.svg?color=green)](https://github.com/pyapp-kit/in-n-out/raw/main/LICENSE)\n[![PyPI](https://img.shields.io/pypi/v/in-n-out.svg?color=green)](https://pypi.org/project/in-n-out)\n[![Python Version](https://img.shields.io/pypi/pyversions/in-n-out.svg?color=green)](https://python.org)\n[![CI](https://github.com/pyapp-kit/in-n-out/actions/workflows/ci.yml/badge.svg)](https://github.com/pyapp-kit/in-n-out/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/pyapp-kit/in-n-out/branch/main/graph/badge.svg)](https://app.codecov.io/gh/pyapp-kit/in-n-out)\n[![Benchmarks](https://img.shields.io/badge/⏱-codspeed-%23FF7B53)](https://codspeed.io/pyapp-kit/in-n-out)\n\nPython dependency injection you can taste.\n\nA lightweight dependency injection and result processing framework\nfor Python using type hints. Emphasis is on simplicity, ease of use,\nand minimal impact on source code.\n\n```python\nimport in_n_out as ino\n\n\nclass Thing:\n    def __init__(self, name: str):\n        self.name = name\n\n\n# use ino.inject to create a version of the function\n# that will retrieve the required dependencies at call time\n@ino.inject\ndef func(thing: Thing):\n    return thing.name\n\n\ndef give_me_a_thing() -\u003e Thing:\n    return Thing(\"Thing\")\n\n\n# register a provider of Thing\nino.register_provider(give_me_a_thing)\nprint(func())  # prints \"Thing\"\n\n\ndef give_me_another_thing() -\u003e Thing:\n    return Thing(\"Another Thing\")\n\n\nwith ino.register_provider(give_me_another_thing, weight=10):\n    print(func())  # prints \"Another Thing\"\n```\n\nThis also supports processing *return* values as well\n(injection of intentional side effects):\n\n```python\n\n@ino.inject_processors\ndef func2(thing: Thing) -\u003e str:\n    return thing.name\n\ndef greet_name(name: str):\n    print(f\"Hello, {name}!\")\n\nino.register_processor(greet_name)\n\nfunc2(Thing('Bob'))  # prints \"Hello, Bob!\"\n```\n\n### Alternatives\n\nLots of other python DI frameworks exist, here are a few alternatives to consider:\n\n- \u003chttps://github.com/ets-labs/python-dependency-injector\u003e\n- \u003chttps://github.com/google/pinject\u003e\n- \u003chttps://github.com/ivankorobkov/python-inject\u003e\n- \u003chttps://github.com/alecthomas/injector\u003e\n- \u003chttps://github.com/Finistere/antidote\u003e\n- \u003chttps://github.com/dry-python/returns\u003e\n- \u003chttps://github.com/adriangb/di\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyapp-kit%2Fin-n-out","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyapp-kit%2Fin-n-out","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyapp-kit%2Fin-n-out/lists"}