Metadata-Version: 2.1
Name: dypendence
Version: 0.1.6
Summary: Dependency Injection over Dynaconf
Home-page: https://github.com/VaultVulp/dypendence
License: MIT
Author: VaultVulp
Author-email: me@vaultvulp.dev
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
Requires-Dist: dynaconf (>=3.1.2,<4.0.0)
Project-URL: Repository, https://github.com/VaultVulp/dypendence
Description-Content-Type: text/markdown

![Build Status](https://github.com/VaultVulp/dypendence/workflows/Main/badge.svg)
![Coverage Badge](https://minio.vaultvulp.dev/coverage/VaultVulp/dypendence/coverage.svg)

# Dypendence

Dependency Injection over Dynaconf

## Usage example

Example `settings.toml`

```toml
[DY.FileStorageService]
Type = "S3FileStorage"

[DY.FileStorageService.LocalFileStorage]
some_value = "This is Local File Storage"

[DY.FileStorageService.S3FileStorage]
some_value = "This is S3 File Storage"
```

Example application code:

```python
from dypendence import DY


class FileStorageService(DY):

    def save_file(self) -> str:
        raise NotImplementedError
    
    def get_value_from_settings(self):
        return self.settings.some_value


class LocalFileStorage(FileStorageService):

    def save_file(self) -> str:
        return 'Saved file to local file system'


class S3FileStorage(FileStorageService):

    def save_file(self) -> str:
        return 'Saved file to S3-like storage'


if __name__ == '__main__':
    file_storage = FileStorageService(settings_files=['settings.toml'])

    assert isinstance(file_storage, S3FileStorage)
    assert file_storage.save_file() == 'Saved file to S3-like storage'
    assert file_storage.get_value_from_settings() == 'This is S3 File Storage'
```

