Metadata-Version: 2.1
Name: pyditto
Version: 0.1.2
Summary: 
License: MIT
Author: Alexis Manuel
Author-email: alexis.manuelpro@gmail.com
Requires-Python: >=3.8,<4.0
Classifier: License :: OSI Approved :: MIT 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
Description-Content-Type: text/markdown

# ditto: dependency injection tool

ditto is a simple and lightweight dependency injection tool for Python.

## Features

- Easy-to-use decorators for dependency injection.
- Supports class and instance-based services.
- Sync and Async support

## Installation

```sh
pip install pyditto
```

## Usage
Declare your dependencies to ditto on application start.

```python
import ditto as di

class Pokemon:
    def attack(self) -> str:
        pass

class FirePokemon(Pokemon):
    def attack(self) -> str:
        return 'Ember ! 🔥'

di.register(FirePokemon) # register as a class
di.register(FirePokemon()) # or as an object
```

Then you can inject your dependency into your class:
```python
@di.inject
class Team:
    charmander: FirePokemon

    def battle(self):
        self.charmander.attack()



team = Team()
team.battle() # 'Ember ! 🔥'
```
Or into an isolated function within your class:
```python
class Team:
    
    @di.inject
    def battle(self, charmander: FirePokemon):
        self.charmander.attack()

team = Team()
team.battle() # 'Ember ! 🔥'

```
Or just within a bare function:
```python
@di.inject
def battle(charmander: FirePokemon):
    self.charmander.attack()

battle() # 'Ember ! 🔥'
```

## License
This project is licensed under the MIT License - see the LICENSE file for details.

