{"id":13594745,"url":"https://github.com/meadsteve/lagom","last_synced_at":"2025-05-15T00:12:29.918Z","repository":{"id":37076645,"uuid":"189738708","full_name":"meadsteve/lagom","owner":"meadsteve","description":"📦 Autowiring dependency injection container for python 3","archived":false,"fork":false,"pushed_at":"2024-12-14T09:33:50.000Z","size":605,"stargazers_count":312,"open_issues_count":30,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-14T01:23:21.940Z","etag":null,"topics":["dependency-injection","django","fastapi","flask","mypy","python3","starlette","types"],"latest_commit_sha":null,"homepage":"https://lagom-di.readthedocs.io/en/latest/","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/meadsteve.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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}},"created_at":"2019-06-01T13:54:42.000Z","updated_at":"2025-04-30T12:21:42.000Z","dependencies_parsed_at":"2024-12-14T10:32:25.413Z","dependency_job_id":null,"html_url":"https://github.com/meadsteve/lagom","commit_stats":{"total_commits":423,"total_committers":12,"mean_commits":35.25,"dds":"0.42316784869976354","last_synced_commit":"90db4c2f9fb34f66455551697ad33806970ca9a2"},"previous_names":[],"tags_count":94,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meadsteve%2Flagom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meadsteve%2Flagom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meadsteve%2Flagom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meadsteve%2Flagom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meadsteve","download_url":"https://codeload.github.com/meadsteve/lagom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254249206,"owners_count":22039029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","django","fastapi","flask","mypy","python3","starlette","types"],"created_at":"2024-08-01T16:01:38.656Z","updated_at":"2025-05-15T00:12:24.900Z","avatar_url":"https://github.com/meadsteve.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# [![Lagom](./docs/images/logo_and_text.png)](https://lagom-di.readthedocs.io/en/stable/)\n\n[![](https://img.shields.io/pypi/pyversions/lagom.svg)](https://pypi.org/pypi/lagom/)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/meadsteve/lagom/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/meadsteve/lagom/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/meadsteve/lagom/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/meadsteve/lagom/?branch=master)\n![PyPI](https://img.shields.io/pypi/v/lagom.svg?style=plastic)\n\n## What\nLagom is a dependency injection container designed to give you \"just enough\"\nhelp with building your dependencies. The intention is that almost\nall of your code doesn't know about or rely on lagom. Lagom will\nonly be involved at the top level to pull everything together.\n\n### Features\n\n * Type based auto wiring with zero configuration.\n * Fully based on types. Strong integration with mypy.\n * Minimal changes to existing code.\n * Integration with a few common web frameworks.\n * Support for async python.\n * Thread-safe at runtime\n \nYou can see a [comparison to other frameworks here](https://lagom-di.readthedocs.io/en/stable/comparison/)\n\n## 🎉 Version 2.0.0 is now released! 🎉\nFor users of python 3.7 and above this should require no changes. Full details can be found in the release notes [upgrade instructions](https://lagom-di.readthedocs.io/en/stable/CHANGELOG/#upgrade-instructions).\n\n## Installation\n```bash\npip install lagom\n# or: \n# pipenv install lagom\n# poetry add lagom\n```\nNote: if you decide to clone from source then make sure you use the latest version tag. The `master` branch may contain features that will be removed.\n\nFor the versioning policy read here: [SemVer in Lagom](https://lagom-di.readthedocs.io/en/latest/CONTRIBUTING/#versioning-semver)\n\n## Usage\nEverything in Lagom is based on types. To create an object\nyou pass the type to the container:\n```python\ncontainer = Container()\nsome_thing = container[SomeClass]\n```\n\n### Auto-wiring (with zero configuration)\nMost of the time Lagom doesn't need to be told how to build your classes. If\nthe `__init__` method has type hints then lagom will use these to inject\nthe correct dependencies. The following will work without any special configuration:\n\n```python\nclass MyDataSource:\n    pass\n    \nclass SomeClass:\n   #                        👇 type hint is used by lagom\n   def __init__(datasource: MyDataSource):\n      pass\n\ncontainer = Container()\nsome_thing = container[SomeClass] # An instance of SomeClass will be built with an instance of MyDataSource provided\n```\n\nand later if you extend your class no changes are needed to lagom:\n\n```python\nclass SomeClass:\n    #                                                👇 This is the change.\n    def __init__(datasource: MyDataSource, service: SomeFeatureProvider):\n        pass\n\n# Note the following code is unchanged\ncontainer = Container()\nsome_thing = container[SomeClass] # An instance of SomeClass will be built with an instance of MyDataSource provided\n```\n\n### Singletons\nYou can tell the container that something should be a singleton:\n```python\ncontainer[SomeExpensiveToCreateClass] = SomeExpensiveToCreateClass(\"up\", \"left\")\n```\n\n### Explicit build instructions when required\nYou can explicitly tell the container how to construct something by giving it a function:\n\n```python\ncontainer[SomeClass] = lambda: SomeClass(\"down\", \"spiral\")\n```\n\nAll of this is done without modifying any of your classes. This is one of the design goals of\nlagom. \n\n### Hooks in to existing systems\nA decorator is provided to hook top level functions into the container.\n\n```python\n@bind_to_container(container)\ndef handle_move_post_request(request: typing.Dict, game: Game = lagom.injectable):\n    # do something to the game\n    return Response()\n```\n\n(There's also a few common framework integrations [provided here](https://lagom-di.readthedocs.io/en/stable/framework_integrations/))\n\n[Full docs here here](https://lagom-di.readthedocs.io/en/stable/)\n\n## Contributing\n\nContributions are very welcome. [Please see instructions here](https://lagom-di.readthedocs.io/en/latest/CONTRIBUTING/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeadsteve%2Flagom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeadsteve%2Flagom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeadsteve%2Flagom/lists"}