{"id":13458936,"url":"https://github.com/peter-daly/clean_ioc","last_synced_at":"2026-01-14T07:17:15.445Z","repository":{"id":65470837,"uuid":"592962648","full_name":"peter-daly/clean_ioc","owner":"peter-daly","description":"A simple IoC library for python","archived":false,"fork":false,"pushed_at":"2025-11-03T17:13:50.000Z","size":9950,"stargazers_count":11,"open_issues_count":11,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-11-03T19:15:58.091Z","etag":null,"topics":["dependency-injection","inversion-of-control","python3","types"],"latest_commit_sha":null,"homepage":"https://peter-daly.github.io/clean_ioc/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peter-daly.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-01-24T22:43:29.000Z","updated_at":"2025-11-03T17:13:54.000Z","dependencies_parsed_at":"2023-11-18T21:30:13.339Z","dependency_job_id":"89d301a3-5c74-4372-822b-41124579978f","html_url":"https://github.com/peter-daly/clean_ioc","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"8aebae566769f1a9643e0b100f233f995c2b9a3a"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/peter-daly/clean_ioc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-daly%2Fclean_ioc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-daly%2Fclean_ioc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-daly%2Fclean_ioc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-daly%2Fclean_ioc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peter-daly","download_url":"https://codeload.github.com/peter-daly/clean_ioc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-daly%2Fclean_ioc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28412783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T05:26:33.345Z","status":"ssl_error","status_checked_at":"2026-01-14T05:21:57.251Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency-injection","inversion-of-control","python3","types"],"created_at":"2024-07-31T09:00:59.990Z","updated_at":"2026-01-14T07:17:15.440Z","avatar_url":"https://github.com/peter-daly.png","language":"Python","funding_links":[],"categories":["Software"],"sub_categories":["DI Frameworks / Containers"],"readme":"# Clean IoC\n\nA simple dependency injection library for python that requires nothing of your application code (except that you use typing).\n\nRead the [docs](https://peter-daly.github.io/clean_ioc/) to find out more.\n\n## Basic Registering and resolving\n\nThere are 4 basic modes of registering a new set of classes\n\n### Implementation\n\n```python\n\nclass UserRepository(abc.ABC):\n    @abc.abstractmethod\n    def add(self, user):\n        pass\n\nclass InMemoryUserRepository(UserRepository):\n\n    def __init__(self):\n        self.users = []\n\n    def add(self, user):\n        # This is obviously terrible, but it's for demo purposes\n        self.users.append(user)\n\nclass SqlAlchemyUserRepository(UserRepository):\n\n    def __init__(self):\n        # Do some db stuff here\n        pass\n\n    def add(self, user):\n        # Do some db stuff here\n        pass\n\ncontainer = Container()\ncontainer.register(UserRepository, InMemoryUserRepository)\n\n\nrepository = container.resolve(UserRepository) # This will return an InMemoryUserRepository\n\n```\n\n### Concrete Class\n\n```python\n\nclass ClientDependency:\n    def get_int(self):\n        return 10\n\nclass Client:\n    def __init__(self, dep: ClientDependency):\n        self.dep = dep\n\n    def get_number(self):\n        return self.dep.get_int()\n\n\ncontainer = Container()\ncontainer.register(ClientDependency)\ncontainer.register(Client)\n\nclient = container.resolve(Client)\n\nclient.get_number() # returns 10\n\n```\n\n### Factory\n\n```python\n\nclass ClientDependency:\n    def get_int(self):\n        return 10\n\nclass Client:\n    def __init__(self, dep: ClientDependency):\n        self.dep = dep\n\n    def get_number(self):\n        return self.dep.get_int()\n\ndef client_factory(dep: ClientDependency):\n    return Client(dep=dep)\n\n\ncontainer = Container()\ncontainer.register(ClientDependency)\ncontainer.register(Client, factory=client_factory)\n\nclient = container.resolve(Client)\n\nclient.get_number() # returns 10\n\n```\n\n### Instance\n\n```python\n\nclass ClientDependency:\n    def __init__(self, num):\n        self.num = num\n\n    def get_int(self):\n        return self.num\n\nclass Client:\n    def __init__(self, dep: ClientDependency):\n        self.dep = dep\n\n    def get_number(self):\n        return self.dep.get_int()\n\nclient_dependency = ClientDependency(num=10)\n\ncontainer = Container()\ncontainer.register(ClientDependency, instance=client_dependency)\ncontainer.register(Client)\n\nclient = container.resolve(Client)\n\nclient.get_number() # returns 10\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-daly%2Fclean_ioc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeter-daly%2Fclean_ioc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-daly%2Fclean_ioc/lists"}