{"id":38044542,"url":"https://github.com/fcracker79/yadi","last_synced_at":"2026-01-16T19:57:08.298Z","repository":{"id":57477978,"uuid":"124439254","full_name":"fcracker79/yadi","owner":"fcracker79","description":"Yet Another Dependency Injection framework","archived":false,"fork":false,"pushed_at":"2018-12-16T17:50:43.000Z","size":30,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-24T23:19:50.447Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/fcracker79.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-08T19:39:30.000Z","updated_at":"2025-04-29T14:51:20.000Z","dependencies_parsed_at":"2022-09-10T08:21:45.007Z","dependency_job_id":null,"html_url":"https://github.com/fcracker79/yadi","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/fcracker79/yadi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcracker79%2Fyadi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcracker79%2Fyadi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcracker79%2Fyadi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcracker79%2Fyadi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fcracker79","download_url":"https://codeload.github.com/fcracker79/yadi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcracker79%2Fyadi/sbom","scorecard":{"id":394596,"data":{"date":"2025-08-11","repo":{"name":"github.com/fcracker79/yadi","commit":"e0327295b062c24cf85323c8fcc414c8dc4fe4a4"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-18T18:40:27.294Z","repository_id":57477978,"created_at":"2025-08-18T18:40:27.294Z","updated_at":"2025-08-18T18:40:27.294Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28482151,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: 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":[],"created_at":"2026-01-16T19:57:08.234Z","updated_at":"2026-01-16T19:57:08.287Z","avatar_url":"https://github.com/fcracker79.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![build status](https://img.shields.io/travis/fcracker79/yadi/master.svg?style=flat-square)](https://travis-ci.org/fcracker79/yadi)\n[![Pypi](https://img.shields.io/pypi/v/yadi-framework.svg)](https://img.shields.io/pypi/v/yadi-framework.svg)\n\nYADI\n=================================================\nYet Another Dependency Injection framework\n\nYADI is a dependency injection framework.\nIt supports both classes and function in a declarative fashion.\n\nInstallation\n------------\n\n```sh\npip install yadi-framework\n```\n\nBasic examples\n--------------\n\nThis is a simple injection example:\n\n[//]: # (tmp/readme_md_1.py)\n\n```python\nfrom yadi.context_impl import DEFAULT_CONTEXT\nfrom yadi.decorators import inject\nfrom yadi.types import Yadi\n\n\n@inject()\nclass Component1:\n    pass\n\n\n@inject()\nclass Component2:\n    def __init__(self, c1: Yadi[Component1]):\n        self.c1 = c1\n\n\n@inject()\nclass Component3:\n    def __init__(self, c1: Yadi[Component1]):\n        self.c1 = c1\n\n\nc2 = DEFAULT_CONTEXT.get_bean(Component2)  # type: Component2\nc3 = DEFAULT_CONTEXT.get_bean(Component3)  # type: Component3\nprint(Component1 is type(c2.c1))  # True\nprint(c2.c1 is c3.c1)  # True\n\n```\n\nHere it is an example of how to inject functions:\n\n[//]: # (tmp/readme_md_2.py)\n\n```python\nfrom yadi.context_impl import DEFAULT_CONTEXT\nfrom yadi.decorators import inject\nfrom yadi.types import Yadi\n\n\n@inject()\nclass Component:\n    pass\n\n\n@inject(name='another_function')\ndef h(x, y, z=None):\n    assert isinstance(x, Component)\n    print('Function h:', type(x))\n\n\n@inject(name='my_function')\ndef f(a: Yadi[Component], b, c: Yadi['another_function'] = None, d: str = None):\n    c(a, b, z=d)\n\n\nDEFAULT_CONTEXT.get_bean('my_function')(23, d=5)  # Function h: \u003cclass '__main__.Component'\u003e\n\n```\n\nScopes\n------\nBy default, all the beans are saved as Singleton.\nEach singleton is stored in its context, that is, there is a single instance\n_for each context instance_.\n\nAlternatively, it is possible to save beans as Prototypes, that is, \na different instance is generated whenever the bean is referred to.\n\n[//]: # (tmp/readme_md_3.py)\n\n```python\nfrom yadi import context\nfrom yadi import types\nfrom yadi.context_impl import DEFAULT_CONTEXT\nfrom yadi.decorators import inject\n\n\n@inject(scope=context.PROTOTYPE, name='a component 1')\nclass Component1:\n    pass\n\n\n@inject(name='a component 2')\nclass Component2:\n    def __init__(\n            self,\n            f1: types.Yadi[Component1],\n            f2: types.Yadi['a component 1']):\n        self.f1, self.f2 = f1, f2\n\n\n@inject(name='a component 3')\nclass Component3:\n    def __init__(\n            self,\n            f1: types.Yadi[Component1],\n            f2: types.Yadi['a component 1']):\n        self.f1, self.f2 = f1, f2\n\n\nc2 = DEFAULT_CONTEXT.get_bean('a component 2')  # type: Component2\nc3 = DEFAULT_CONTEXT.get_bean('a component 3')  # type: Component3\n\nprint(isinstance(c2.f1, Component1))  # True\nprint(isinstance(c2.f2, Component1))  # True\n\nprint(isinstance(c3.f1, Component1))  # True\nprint(isinstance(c3.f2, Component1))  # True\n\nprint(c2.f1 == c2.f2)  # False\nprint(c3.f1 == c3.f2)  # False\nprint(c2.f1 == c3.f1)  # False\nprint(c2.f1 == c3.f2)  # False\nprint(c2.f2 == c3.f1)  # False\nprint(c2.f2 == c3.f2)  # False\n\n```\n\nIt is also possible to define custom scopes and add\nthem to a context.\n\nHere it is an example of thread-local scope:\n\n[//]: # (tmp/readme_md_3.py)\n\n```python\nimport threading\n\nfrom yadi.context import Scope\nfrom yadi.context_impl import DEFAULT_CONTEXT\nfrom yadi.decorators import inject\n\n\nclass ThreadLocalScope(Scope):\n    def __init__(self):\n        self._tl = threading.local()\n\n    def get(self, key: str):\n        return getattr(self._tl, key, None)\n\n    def set(self, key: str, obj: object):\n        setattr(self._tl, key, obj)\n\n    @property\n    def name(self):\n        return 'threadlocal'\n\n    @property\n    def level(self):\n        return 100\n\n\nDEFAULT_CONTEXT.add_scope(ThreadLocalScope())\n\n\n@inject(scope='threadlocal', name='a component 1')\nclass Component1:\n    pass\n\n\nc1 = DEFAULT_CONTEXT.get_bean('a component 1')\nc1_2 = DEFAULT_CONTEXT.get_bean('a component 1')\n\nthread_c1 = []\nc1_t = None\n\n\ndef _f():\n    global c1_t\n    c1_t = DEFAULT_CONTEXT.get_bean('a component 1')\n    print(c1_t == DEFAULT_CONTEXT.get_bean('a component 1'))  # True\n    thread_c1.append(c1_t)\n\n\nt = threading.Thread(target=_f)\nt.start()\nt.join()\n\nprint(c1 == c1_2)  # True\nprint(c1 == c1_t)  # False\n\n```\n\n**Scoped proxies**\n\nLet's suppose to inject a thread-local scoped bean in a singleton.\nAs a result, different thread sharing the same singleton should not\nshare the same thread local bean, which is not possible.\n\nIn order to solve this issue, YADI creates a proxy around the injected\nbean that delegates any access to the current bean in the context.\n\nMore in general, scopes have a `level` attribute: if the injected bean\nhas a higher scope level than the container bean, the injected bean is wrapped\ninto a scoped proxy.\n\nHere it is an example of scoped proxies (don't worry, you do not have to do \nanything to make it work).\n\n[//]: # (tmp/readme_md_5.py)\n\n```python\nimport random\nimport threading\n\nfrom yadi.bean_factories import _ScopedProxy\nfrom yadi.context import Scope\nfrom yadi.context_impl import DEFAULT_CONTEXT\nfrom yadi.decorators import inject\nfrom yadi.types import Yadi\n\n\nclass ThreadLocalScope(Scope):\n    def __init__(self):\n        self._tl = threading.local()\n\n    def get(self, key: str):\n        return getattr(self._tl, key, None)\n\n    def set(self, key: str, obj: object):\n        setattr(self._tl, key, obj)\n\n    @property\n    def name(self):\n        return 'threadlocal'\n\n    @property\n    def level(self):\n        return 100\n\n\nDEFAULT_CONTEXT.add_scope(ThreadLocalScope())\n\n\n@inject(scope='threadlocal')\nclass Component1:\n    def __init__(self):\n        self.object_id = random.randint(0, 1000000)\n\n\n@inject(name='a component')\nclass Component2:\n    def __init__(self, f1: Yadi[Component1]):\n        self.f1 = f1\n\n\ncomponent = DEFAULT_CONTEXT.get_bean('a component')\ncomponent_thread_id = []\nprint('Main thread, scoped proxy type', type(component.f1) == _ScopedProxy)  # Main thread, scoped proxy type True\n\n\ndef _f():\n    component_thread = DEFAULT_CONTEXT.get_bean('a component')\n    print('Subthread, scoped proxy type', type(component_thread.f1) == _ScopedProxy)\n    component_thread_id.append(component_thread.f1.object_id)\n    print(\n        'Subthread, bean id',\n        component_thread.f1.object_id == DEFAULT_CONTEXT.get_bean('a component').f1.object_id)\n\n\nt = threading.Thread(target=_f)\nt.start()\nt.join()  # Subthread, scoped proxy type True\n          # Subthread, bean id True\n\nprint('Main thread, bean id', component.f1.object_id == component_thread_id[0])  # Main thread, bean id False\n\n```\nContexts\n--------\nAll the components are kept in a context.\n\nBy default, the `inject` decorator keeps the beans instances in `yadi.context_impl.DEFAULT_CONTEXT`.\n\nYou might want to instantiate a new context and pass it as a `context` keyword argument of `inject` decorator.\n\nLife cycle\n----------\nIt is possible to trigger beans whenever one of them is created.\nIn order to define the method(s) to trigger, it is necessary to decorated\nthem with `post_create`, as follows:\n\n[//]: # (tmp/readme_md_5.py)\n\n```python\nfrom yadi.context_impl import DEFAULT_CONTEXT\nfrom yadi.decorators import inject, post_create\nfrom yadi.types import Yadi\n\n\n@inject()\nclass Component1:\n    pass\n\n@inject()\nclass Component2:\n    def __init__(self, c1: Yadi[Component1]):\n        self.c1 = c1\n        self.invoked_post_create = 0\n\n    @post_create\n    def finished_creating(self):\n        print('Component 1:', self.c1)  # Component 1: \u003c__main__.Component1 object at 0x7f42e90d2e48\u003e\n        self.invoked_post_create += 1\n\n\ncomponent_2 = DEFAULT_CONTEXT.get_bean(Component2)  # type: Component2\nprint('post_create invokations:', component_2.invoked_post_create)  # post_create invokations: 1\nDEFAULT_CONTEXT.get_bean(Component2)\nprint('post_create invokations:', component_2.invoked_post_create)  # post_create invokations: 1\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffcracker79%2Fyadi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffcracker79%2Fyadi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffcracker79%2Fyadi/lists"}