Skip to main content

Dependency Injection over Dynaconf

Project description

Build Status Coverage Badge


Dependency Injection over Dynaconf

Usage example

Example settings.toml

Type = "S3FileStorage"

some_value = "This is Local File Storage"

some_value = "This is S3 File Storage"

Example application code:

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'

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dypendence-0.1.6.tar.gz (3.2 kB view hashes)

Uploaded source

Built Distribution

dypendence-0.1.6-py3-none-any.whl (3.3 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page