Skip to main content

Dependency Injection over Dynaconf

Project description

Build Status Coverage Badge

Dypendence

Dependency Injection over Dynaconf

Usage example

Example settings.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:

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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file dypendence-0.1.6.tar.gz.

File metadata

  • Download URL: dypendence-0.1.6.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.2 CPython/3.8.6 Linux/5.4.0-1026-azure

File hashes

Hashes for dypendence-0.1.6.tar.gz
Algorithm Hash digest
SHA256 e5e19c03ba84a733701417a2d2c2408697d658973d3234b35ec5fcf1a7a628a4
MD5 d004410c7353001f019874186d1020c9
BLAKE2b-256 3d96b91e6bf7da1ae1f7edee1185db01b3ec68d574c03a4b3443a734802fc29b

See more details on using hashes here.

File details

Details for the file dypendence-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: dypendence-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.2 CPython/3.8.6 Linux/5.4.0-1026-azure

File hashes

Hashes for dypendence-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 577178fd56346d660201fa2d0d30a906f5a53dde891d75d5b869961875550f95
MD5 2a7393a0f750d0b96de3857e1aa793ec
BLAKE2b-256 75ee6f6ea3e1205d853a6c843e40c792e673005ac810f5024458cf9a24ce72f5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page