Metadata-Version: 2.3 Name: in-n-out Version: 0.2.1 Summary: plugable dependency injection and result processing Project-URL: homepage, https://github.com/pyapp-kit/in-n-out Project-URL: repository, https://github.com/pyapp-kit/in-n-out Project-URL: documentations, https://ino.rtfd.io Author-email: Talley Lambert License: BSD 3-Clause License License-File: LICENSE Classifier: Development Status :: 3 - Alpha Classifier: License :: OSI Approved :: BSD License Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Typing :: Typed Requires-Python: >=3.8 Provides-Extra: dev Requires-Dist: ipython; extra == 'dev' Requires-Dist: mypy; extra == 'dev' Requires-Dist: pdbpp; extra == 'dev' Requires-Dist: pre-commit; extra == 'dev' Requires-Dist: pytest-codspeed; extra == 'dev' Requires-Dist: pytest-cov; extra == 'dev' Requires-Dist: pytest>=6.0; extra == 'dev' Requires-Dist: rich; extra == 'dev' Requires-Dist: ruff; extra == 'dev' Requires-Dist: toolz; extra == 'dev' Provides-Extra: docs Requires-Dist: mkdocs-gen-files; extra == 'docs' Requires-Dist: mkdocs-literate-nav; extra == 'docs' Requires-Dist: mkdocs-material==9.4.1; extra == 'docs' Requires-Dist: mkdocs==1.5.3; extra == 'docs' Requires-Dist: mkdocstrings-python==1.7.3; extra == 'docs' Provides-Extra: test Requires-Dist: pytest-codspeed; extra == 'test' Requires-Dist: pytest-cov; extra == 'test' Requires-Dist: pytest>=6.0; extra == 'test' Requires-Dist: toolz; extra == 'test' Description-Content-Type: text/markdown # in-n-out [![License](https://img.shields.io/pypi/l/in-n-out.svg?color=green)](https://github.com/pyapp-kit/in-n-out/raw/main/LICENSE) [![PyPI](https://img.shields.io/pypi/v/in-n-out.svg?color=green)](https://pypi.org/project/in-n-out) [![Python Version](https://img.shields.io/pypi/pyversions/in-n-out.svg?color=green)](https://python.org) [![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) [![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) [![Benchmarks](https://img.shields.io/badge/⏱-codspeed-%23FF7B53)](https://codspeed.io/pyapp-kit/in-n-out) Python dependency injection you can taste. A lightweight dependency injection and result processing framework for Python using type hints. Emphasis is on simplicity, ease of use, and minimal impact on source code. ```python import in_n_out as ino class Thing: def __init__(self, name: str): self.name = name # use ino.inject to create a version of the function # that will retrieve the required dependencies at call time @ino.inject def func(thing: Thing): return thing.name def give_me_a_thing() -> Thing: return Thing("Thing") # register a provider of Thing ino.register_provider(give_me_a_thing) print(func()) # prints "Thing" def give_me_another_thing() -> Thing: return Thing("Another Thing") with ino.register_provider(give_me_another_thing, weight=10): print(func()) # prints "Another Thing" ``` This also supports processing *return* values as well (injection of intentional side effects): ```python @ino.inject_processors def func2(thing: Thing) -> str: return thing.name def greet_name(name: str): print(f"Hello, {name}!") ino.register_processor(greet_name) func2(Thing('Bob')) # prints "Hello, Bob!" ``` ### Alternatives Lots of other python DI frameworks exist, here are a few alternatives to consider: - - - - - - -