injectq 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- injectq-0.1.0/.github/instructions/config.instructions.md +7 -0
- injectq-0.1.0/.gitignore +77 -0
- injectq-0.1.0/INJECTQ_SPECIFICATION.md +434 -0
- injectq-0.1.0/LICENSE +21 -0
- injectq-0.1.0/Makefile +32 -0
- injectq-0.1.0/PKG-INFO +109 -0
- injectq-0.1.0/README.md +63 -0
- injectq-0.1.0/docks_plan.md +0 -0
- injectq-0.1.0/docs/advanced/async-support.md +704 -0
- injectq-0.1.0/docs/advanced/circular-dependencies.md +850 -0
- injectq-0.1.0/docs/advanced/diagnostics.md +712 -0
- injectq-0.1.0/docs/advanced/middleware.md +718 -0
- injectq-0.1.0/docs/advanced/overview.md +519 -0
- injectq-0.1.0/docs/advanced/performance-optimization.md +754 -0
- injectq-0.1.0/docs/advanced/plugins.md +1091 -0
- injectq-0.1.0/docs/advanced/profiling.md +924 -0
- injectq-0.1.0/docs/advanced/resource-management.md +813 -0
- injectq-0.1.0/docs/advanced/thread-safety.md +768 -0
- injectq-0.1.0/docs/advanced-features/circular-dependencies.md +850 -0
- injectq-0.1.0/docs/advanced-features/diagnostics.md +712 -0
- injectq-0.1.0/docs/advanced-features/overview.md +519 -0
- injectq-0.1.0/docs/advanced-features/performance-optimization.md +754 -0
- injectq-0.1.0/docs/advanced-features/profiling.md +924 -0
- injectq-0.1.0/docs/advanced-features/resource-management.md +813 -0
- injectq-0.1.0/docs/advanced-features/thread-safety.md +768 -0
- injectq-0.1.0/docs/api-reference/container.md +128 -0
- injectq-0.1.0/docs/api-reference/decorators.md +363 -0
- injectq-0.1.0/docs/api-reference/diagnostics.md +699 -0
- injectq-0.1.0/docs/api-reference/exceptions.md +688 -0
- injectq-0.1.0/docs/api-reference/index.md +43 -0
- injectq-0.1.0/docs/api-reference/integrations.md +734 -0
- injectq-0.1.0/docs/api-reference/module.md +253 -0
- injectq-0.1.0/docs/api-reference/providers.md +543 -0
- injectq-0.1.0/docs/api-reference/registry.md +422 -0
- injectq-0.1.0/docs/api-reference/resolver.md +494 -0
- injectq-0.1.0/docs/api-reference/scopes.md +442 -0
- injectq-0.1.0/docs/api-reference/testing.md +635 -0
- injectq-0.1.0/docs/api-reference/types.md +728 -0
- injectq-0.1.0/docs/api-reference/validation.md +657 -0
- injectq-0.1.0/docs/best-practices/architectural-patterns.md +1438 -0
- injectq-0.1.0/docs/best-practices/performance.md +710 -0
- injectq-0.1.0/docs/best-practices/security.md +1030 -0
- injectq-0.1.0/docs/best-practices/testing-strategies.md +1330 -0
- injectq-0.1.0/docs/changelog.md +210 -0
- injectq-0.1.0/docs/contributing.md +420 -0
- injectq-0.1.0/docs/core-concepts/container-pattern.md +604 -0
- injectq-0.1.0/docs/core-concepts/service-lifetimes.md +593 -0
- injectq-0.1.0/docs/core-concepts/type-safety.md +537 -0
- injectq-0.1.0/docs/core-concepts/what-is-di.md +349 -0
- injectq-0.1.0/docs/examples/architectural-examples.md +1207 -0
- injectq-0.1.0/docs/examples/design-patterns.md +1564 -0
- injectq-0.1.0/docs/examples/practical-examples.md +1279 -0
- injectq-0.1.0/docs/framework-integrations/fastapi-integration.md +708 -0
- injectq-0.1.0/docs/framework-integrations/fastmcp-integration.md +1054 -0
- injectq-0.1.0/docs/framework-integrations/overview.md +532 -0
- injectq-0.1.0/docs/framework-integrations/taskiq-integration.md +861 -0
- injectq-0.1.0/docs/getting-started/first-app.md +499 -0
- injectq-0.1.0/docs/getting-started/installation.md +107 -0
- injectq-0.1.0/docs/getting-started/quick-start.md +225 -0
- injectq-0.1.0/docs/index.md +157 -0
- injectq-0.1.0/docs/injection-patterns/binding-patterns.md +606 -0
- injectq-0.1.0/docs/injection-patterns/dict-interface.md +395 -0
- injectq-0.1.0/docs/injection-patterns/inject-decorator.md +475 -0
- injectq-0.1.0/docs/injection-patterns/inject-function.md +472 -0
- injectq-0.1.0/docs/integrations/fastapi-integration.md +708 -0
- injectq-0.1.0/docs/integrations/fastmcp-integration.md +1054 -0
- injectq-0.1.0/docs/integrations/overview.md +532 -0
- injectq-0.1.0/docs/integrations/taskiq-integration.md +861 -0
- injectq-0.1.0/docs/migration/kink.md +601 -0
- injectq-0.1.0/docs/migration/other-frameworks.md +695 -0
- injectq-0.1.0/docs/migration/python-injector.md +691 -0
- injectq-0.1.0/docs/migration-guides/kink.md +601 -0
- injectq-0.1.0/docs/migration-guides/other-frameworks.md +695 -0
- injectq-0.1.0/docs/migration-guides/python-injector.md +691 -0
- injectq-0.1.0/docs/modules/configuration-modules.md +587 -0
- injectq-0.1.0/docs/modules/module-best-practices.md +718 -0
- injectq-0.1.0/docs/modules/module-composition.md +802 -0
- injectq-0.1.0/docs/modules/overview.md +546 -0
- injectq-0.1.0/docs/modules/provider-modules.md +722 -0
- injectq-0.1.0/docs/modules-providers/configuration-modules.md +587 -0
- injectq-0.1.0/docs/modules-providers/module-best-practices.md +718 -0
- injectq-0.1.0/docs/modules-providers/module-composition.md +802 -0
- injectq-0.1.0/docs/modules-providers/overview.md +546 -0
- injectq-0.1.0/docs/modules-providers/provider-modules.md +722 -0
- injectq-0.1.0/docs/scopes/custom-scopes.md +880 -0
- injectq-0.1.0/docs/scopes/scope-best-practices.md +710 -0
- injectq-0.1.0/docs/scopes/scoped-services.md +761 -0
- injectq-0.1.0/docs/scopes/singleton-scope.md +478 -0
- injectq-0.1.0/docs/scopes/transient-scope.md +578 -0
- injectq-0.1.0/docs/scopes/understanding-scopes.md +465 -0
- injectq-0.1.0/docs/testing/integration-testing.md +732 -0
- injectq-0.1.0/docs/testing/mocking-strategies.md +682 -0
- injectq-0.1.0/docs/testing/override-patterns.md +655 -0
- injectq-0.1.0/docs/testing/overview.md +492 -0
- injectq-0.1.0/docs/testing/test-scopes.md +844 -0
- injectq-0.1.0/docs/testing/testing-best-practices.md +617 -0
- injectq-0.1.0/docs/testing/testing-utilities.md +644 -0
- injectq-0.1.0/examples/advanced_features_example.py +457 -0
- injectq-0.1.0/examples/comprehensive_example.py +269 -0
- injectq-0.1.0/examples/ex.py +41 -0
- injectq-0.1.0/examples/example.py +159 -0
- injectq-0.1.0/examples/fastapi_integration_example.py +0 -0
- injectq-0.1.0/examples/final_example.py +208 -0
- injectq-0.1.0/injectq/__init__.py +145 -0
- injectq-0.1.0/injectq/components/__init__.py +623 -0
- injectq-0.1.0/injectq/core/__init__.py +36 -0
- injectq-0.1.0/injectq/core/async_scopes.py +328 -0
- injectq-0.1.0/injectq/core/base_scope_manager.py +39 -0
- injectq-0.1.0/injectq/core/container.py +368 -0
- injectq-0.1.0/injectq/core/registry.py +176 -0
- injectq-0.1.0/injectq/core/resolver.py +288 -0
- injectq-0.1.0/injectq/core/scopes.py +243 -0
- injectq-0.1.0/injectq/core/thread_safe_resolver.py +495 -0
- injectq-0.1.0/injectq/core/thread_safety.py +313 -0
- injectq-0.1.0/injectq/decorators/__init__.py +28 -0
- injectq-0.1.0/injectq/decorators/inject.py +230 -0
- injectq-0.1.0/injectq/decorators/resource.py +413 -0
- injectq-0.1.0/injectq/decorators/singleton.py +141 -0
- injectq-0.1.0/injectq/diagnostics/__init__.py +8 -0
- injectq-0.1.0/injectq/diagnostics/profiling.py +415 -0
- injectq-0.1.0/injectq/diagnostics/validation.py +476 -0
- injectq-0.1.0/injectq/diagnostics/visualization.py +509 -0
- injectq-0.1.0/injectq/integrations/__init__.py +0 -0
- injectq-0.1.0/injectq/integrations/fastapi.py +49 -0
- injectq-0.1.0/injectq/integrations/taskiq.py +82 -0
- injectq-0.1.0/injectq/modules/__init__.py +12 -0
- injectq-0.1.0/injectq/modules/base.py +201 -0
- injectq-0.1.0/injectq/py.typed +3 -0
- injectq-0.1.0/injectq/testing/__init__.py +22 -0
- injectq-0.1.0/injectq/testing/utilities.py +192 -0
- injectq-0.1.0/injectq/utils/__init__.py +92 -0
- injectq-0.1.0/injectq/utils/exceptions.py +36 -0
- injectq-0.1.0/injectq/utils/helpers.py +141 -0
- injectq-0.1.0/injectq/utils/protocols.py +156 -0
- injectq-0.1.0/injectq/utils/types.py +116 -0
- injectq-0.1.0/mkdocs.yml +196 -0
- injectq-0.1.0/pyproject.toml +290 -0
- injectq-0.1.0/site/404.html +1490 -0
- injectq-0.1.0/site/advanced/async-support/index.html +2650 -0
- injectq-0.1.0/site/advanced/circular-dependencies/index.html +2301 -0
- injectq-0.1.0/site/advanced/diagnostics/index.html +2166 -0
- injectq-0.1.0/site/advanced/middleware/index.html +2636 -0
- injectq-0.1.0/site/advanced/overview/index.html +1993 -0
- injectq-0.1.0/site/advanced/performance-optimization/index.html +2759 -0
- injectq-0.1.0/site/advanced/plugins/index.html +2971 -0
- injectq-0.1.0/site/advanced/profiling/index.html +2384 -0
- injectq-0.1.0/site/advanced/resource-management/index.html +2794 -0
- injectq-0.1.0/site/advanced/thread-safety/index.html +2787 -0
- injectq-0.1.0/site/api-reference/container/index.html +2167 -0
- injectq-0.1.0/site/api-reference/decorators/index.html +2498 -0
- injectq-0.1.0/site/api-reference/diagnostics/index.html +2734 -0
- injectq-0.1.0/site/api-reference/exceptions/index.html +2713 -0
- injectq-0.1.0/site/api-reference/index.html +1930 -0
- injectq-0.1.0/site/api-reference/integrations/index.html +2813 -0
- injectq-0.1.0/site/api-reference/module/index.html +2338 -0
- injectq-0.1.0/site/api-reference/providers/index.html +2683 -0
- injectq-0.1.0/site/api-reference/registry/index.html +2520 -0
- injectq-0.1.0/site/api-reference/resolver/index.html +2610 -0
- injectq-0.1.0/site/api-reference/scopes/index.html +2590 -0
- injectq-0.1.0/site/api-reference/testing/index.html +2676 -0
- injectq-0.1.0/site/api-reference/types/index.html +2757 -0
- injectq-0.1.0/site/api-reference/validation/index.html +2724 -0
- injectq-0.1.0/site/assets/images/favicon.png +0 -0
- injectq-0.1.0/site/assets/javascripts/bundle.92b07e13.min.js +16 -0
- injectq-0.1.0/site/assets/javascripts/bundle.92b07e13.min.js.map +7 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.ar.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.da.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.de.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.du.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.el.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.es.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.fi.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.fr.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.he.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.hi.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.hu.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.hy.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.it.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.ja.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.jp.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.kn.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.ko.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.multi.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.nl.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.no.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.pt.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.ro.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.ru.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.sa.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.stemmer.support.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.sv.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.ta.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.te.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.th.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.tr.min.js +18 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.vi.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/min/lunr.zh.min.js +1 -0
- injectq-0.1.0/site/assets/javascripts/lunr/tinyseg.js +206 -0
- injectq-0.1.0/site/assets/javascripts/lunr/wordcut.js +6708 -0
- injectq-0.1.0/site/assets/javascripts/workers/search.973d3a69.min.js +42 -0
- injectq-0.1.0/site/assets/javascripts/workers/search.973d3a69.min.js.map +7 -0
- injectq-0.1.0/site/assets/stylesheets/main.7e37652d.min.css +1 -0
- injectq-0.1.0/site/assets/stylesheets/main.7e37652d.min.css.map +1 -0
- injectq-0.1.0/site/assets/stylesheets/palette.06af60db.min.css +1 -0
- injectq-0.1.0/site/assets/stylesheets/palette.06af60db.min.css.map +1 -0
- injectq-0.1.0/site/best-practices/architectural-patterns/index.html +3232 -0
- injectq-0.1.0/site/best-practices/performance/index.html +2613 -0
- injectq-0.1.0/site/best-practices/security/index.html +2913 -0
- injectq-0.1.0/site/best-practices/testing-strategies/index.html +3151 -0
- injectq-0.1.0/site/changelog/index.html +2124 -0
- injectq-0.1.0/site/contributing/index.html +2288 -0
- injectq-0.1.0/site/core-concepts/container-pattern/index.html +2677 -0
- injectq-0.1.0/site/core-concepts/service-lifetimes/index.html +2545 -0
- injectq-0.1.0/site/core-concepts/type-safety/index.html +2501 -0
- injectq-0.1.0/site/core-concepts/what-is-di/index.html +2274 -0
- injectq-0.1.0/site/examples/architectural-examples/index.html +2920 -0
- injectq-0.1.0/site/examples/design-patterns/index.html +3293 -0
- injectq-0.1.0/site/examples/practical-examples/index.html +3028 -0
- injectq-0.1.0/site/getting-started/first-app/index.html +2269 -0
- injectq-0.1.0/site/getting-started/installation/index.html +1901 -0
- injectq-0.1.0/site/getting-started/quick-start/index.html +1988 -0
- injectq-0.1.0/site/index.html +1837 -0
- injectq-0.1.0/site/injection-patterns/binding-patterns/index.html +2641 -0
- injectq-0.1.0/site/injection-patterns/dict-interface/index.html +2281 -0
- injectq-0.1.0/site/injection-patterns/inject-decorator/index.html +2467 -0
- injectq-0.1.0/site/injection-patterns/inject-function/index.html +2486 -0
- injectq-0.1.0/site/integrations/fastapi-integration/index.html +2163 -0
- injectq-0.1.0/site/integrations/fastmcp-integration/index.html +2512 -0
- injectq-0.1.0/site/integrations/overview/index.html +1996 -0
- injectq-0.1.0/site/integrations/taskiq-integration/index.html +2319 -0
- injectq-0.1.0/site/migration/kink/index.html +2068 -0
- injectq-0.1.0/site/migration/other-frameworks/index.html +2228 -0
- injectq-0.1.0/site/migration/python-injector/index.html +2148 -0
- injectq-0.1.0/site/modules/configuration-modules/index.html +2576 -0
- injectq-0.1.0/site/modules/module-best-practices/index.html +2164 -0
- injectq-0.1.0/site/modules/module-composition/index.html +2779 -0
- injectq-0.1.0/site/modules/overview/index.html +1982 -0
- injectq-0.1.0/site/modules/provider-modules/index.html +2162 -0
- injectq-0.1.0/site/scopes/custom-scopes/index.html +2902 -0
- injectq-0.1.0/site/scopes/scope-best-practices/index.html +2748 -0
- injectq-0.1.0/site/scopes/scoped-services/index.html +2815 -0
- injectq-0.1.0/site/scopes/singleton-scope/index.html +2510 -0
- injectq-0.1.0/site/scopes/transient-scope/index.html +2612 -0
- injectq-0.1.0/site/scopes/understanding-scopes/index.html +2496 -0
- injectq-0.1.0/site/search/search_index.json +1 -0
- injectq-0.1.0/site/sitemap.xml +283 -0
- injectq-0.1.0/site/sitemap.xml.gz +0 -0
- injectq-0.1.0/site/testing/integration-testing/index.html +2731 -0
- injectq-0.1.0/site/testing/mocking-strategies/index.html +2141 -0
- injectq-0.1.0/site/testing/override-patterns/index.html +2115 -0
- injectq-0.1.0/site/testing/overview/index.html +1950 -0
- injectq-0.1.0/site/testing/test-scopes/index.html +2302 -0
- injectq-0.1.0/site/testing/testing-best-practices/index.html +2088 -0
- injectq-0.1.0/site/testing/testing-utilities/index.html +2098 -0
- injectq-0.1.0/smoke_test.py +91 -0
- injectq-0.1.0/tests/test_async_scopes.py +174 -0
- injectq-0.1.0/tests/test_components.py +437 -0
- injectq-0.1.0/tests/test_container.py +275 -0
- injectq-0.1.0/tests/test_diagnostics.py +509 -0
- injectq-0.1.0/tests/test_fastapi_integration.py +34 -0
- injectq-0.1.0/tests/test_inject.py +238 -0
- injectq-0.1.0/tests/test_modules.py +184 -0
- injectq-0.1.0/tests/test_resource.py +195 -0
- injectq-0.1.0/tests/test_taskiq_integration.py +41 -0
- injectq-0.1.0/tests/test_thread_safety.py +344 -0
- injectq-0.1.0/uv.lock +1633 -0
injectq-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.pyc
|
|
6
|
+
*.pyo
|
|
7
|
+
*.pyd
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Virtual environments
|
|
55
|
+
.env
|
|
56
|
+
.venv
|
|
57
|
+
env/
|
|
58
|
+
venv/
|
|
59
|
+
ENV/
|
|
60
|
+
env.bak/
|
|
61
|
+
venv.bak/
|
|
62
|
+
|
|
63
|
+
# IDE and editor files
|
|
64
|
+
.vscode/
|
|
65
|
+
.idea/
|
|
66
|
+
*.swp
|
|
67
|
+
*.swo
|
|
68
|
+
*~
|
|
69
|
+
|
|
70
|
+
# OS generated files
|
|
71
|
+
.DS_Store
|
|
72
|
+
.DS_Store?
|
|
73
|
+
._*
|
|
74
|
+
.Spotlight-V100
|
|
75
|
+
.Trashes
|
|
76
|
+
ehthumbs.db
|
|
77
|
+
Thumbs.db
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
# InjectQ - Complete Library Specification
|
|
2
|
+
|
|
3
|
+
## Executive Summary
|
|
4
|
+
|
|
5
|
+
InjectQ is a modern Python dependency injection library that combines the simplicity of kink, the power of python-injector, and the advanced features of modern DI frameworks like dishka and wireup. It provides a "best of all worlds" approach with multiple API styles, native framework integrations, and performance optimizations.
|
|
6
|
+
|
|
7
|
+
## Core Value Propositions
|
|
8
|
+
|
|
9
|
+
1. **Simplicity First**: Start with simple dict-like interface, grow into advanced features
|
|
10
|
+
2. **Multiple API Styles**: Choose between `@inject` decorators and `Inject()` functions
|
|
11
|
+
3. **Modern Framework Native**: Built-in support for FastAPI, Taskiq, and FastMCP
|
|
12
|
+
4. **Performance Optimized**: Compile-time dependency resolution with caching
|
|
13
|
+
5. **Type Safe**: Full mypy compliance with early error detection
|
|
14
|
+
6. **Resource Management**: Automatic cleanup and finalization
|
|
15
|
+
|
|
16
|
+
## Complete API Design
|
|
17
|
+
|
|
18
|
+
### 1. Core Container API
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from injectq import InjectQ, singleton, inject, Injectable, Inject
|
|
22
|
+
|
|
23
|
+
# Default container (singleton pattern)
|
|
24
|
+
container = InjectQ.get_instance()
|
|
25
|
+
|
|
26
|
+
# Custom container (when needed)
|
|
27
|
+
custom_container = InjectQ()
|
|
28
|
+
|
|
29
|
+
# Dict-like interface for simple binding
|
|
30
|
+
container[str] = "configuration_value"
|
|
31
|
+
container["database_url"] = "postgresql://localhost/db"
|
|
32
|
+
container[DatabaseConfig] = DatabaseConfig(host="localhost")
|
|
33
|
+
|
|
34
|
+
# Enhanced binding methods
|
|
35
|
+
container.bind(UserService, UserServiceImpl)
|
|
36
|
+
container.bind(UserService, UserServiceImpl, scope="singleton")
|
|
37
|
+
container.bind("cache", lambda c: RedisCache(c["redis_url"]))
|
|
38
|
+
|
|
39
|
+
# Factory services (new instance each time)
|
|
40
|
+
container.factories[TempFile] = lambda c: tempfile.NamedTemporaryFile()
|
|
41
|
+
container.factories["request_id"] = lambda c: str(uuid.uuid4())
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 2. Injection Patterns
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
# Method 1: @inject decorator (recommended)
|
|
48
|
+
@inject
|
|
49
|
+
def process_data(data: str, service: UserService, cache: CacheService):
|
|
50
|
+
# All dependencies auto-injected by type hints
|
|
51
|
+
pass
|
|
52
|
+
|
|
53
|
+
@inject
|
|
54
|
+
async def async_process(data: str, db: AsyncDatabase):
|
|
55
|
+
# Full async support
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
# Method 2: Inject() function (explicit)
|
|
59
|
+
def process_data_explicit(data: str, service=Inject(UserService)):
|
|
60
|
+
# Explicit injection for specific parameters
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
# Method 3: Manual resolution
|
|
64
|
+
def manual_process(data: str):
|
|
65
|
+
service = container.get(UserService)
|
|
66
|
+
# Manual when full control needed
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 3. Class-Based Injection
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
# Singleton classes
|
|
73
|
+
@singleton
|
|
74
|
+
class DatabaseConnection:
|
|
75
|
+
def __init__(self, url: str):
|
|
76
|
+
self.url = url
|
|
77
|
+
|
|
78
|
+
@singleton
|
|
79
|
+
class UserService:
|
|
80
|
+
@inject
|
|
81
|
+
def __init__(self, db: DatabaseConnection, cache: CacheService):
|
|
82
|
+
self.db = db
|
|
83
|
+
self.cache = cache
|
|
84
|
+
|
|
85
|
+
# Scoped classes
|
|
86
|
+
@scoped("request") # New in Phase 3
|
|
87
|
+
class RequestContext:
|
|
88
|
+
@inject
|
|
89
|
+
def __init__(self, request_id: str):
|
|
90
|
+
self.request_id = request_id
|
|
91
|
+
|
|
92
|
+
# Transient classes (new instance each time)
|
|
93
|
+
@transient
|
|
94
|
+
class OrderProcessor:
|
|
95
|
+
@inject
|
|
96
|
+
def __init__(self, db: DatabaseConnection):
|
|
97
|
+
self.db = db
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 4. Provider and Module System
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from injectq import Module, provider
|
|
104
|
+
|
|
105
|
+
class DatabaseModule(Module):
|
|
106
|
+
def configure(self, binder):
|
|
107
|
+
binder.bind(DatabaseConfig, to=self.create_config())
|
|
108
|
+
|
|
109
|
+
@singleton
|
|
110
|
+
@provider
|
|
111
|
+
def provide_connection(self, config: DatabaseConfig) -> DatabaseConnection:
|
|
112
|
+
return create_connection(config.url)
|
|
113
|
+
|
|
114
|
+
@provider
|
|
115
|
+
def provide_session_factory(self, conn: DatabaseConnection) -> Callable:
|
|
116
|
+
return lambda: create_session(conn)
|
|
117
|
+
|
|
118
|
+
class ServiceModule(Module):
|
|
119
|
+
def configure(self, binder):
|
|
120
|
+
binder.bind(UserService, scope="singleton")
|
|
121
|
+
binder.bind(OrderService, scope="scoped")
|
|
122
|
+
|
|
123
|
+
# Container setup with modules
|
|
124
|
+
container = InjectQ([DatabaseModule(), ServiceModule()])
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 5. Resource Management with Finalization
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from injectq import resource
|
|
131
|
+
|
|
132
|
+
@resource
|
|
133
|
+
def database_connection(config: DatabaseConfig) -> Iterator[DatabaseConnection]:
|
|
134
|
+
conn = create_connection(config.url)
|
|
135
|
+
try:
|
|
136
|
+
yield conn
|
|
137
|
+
finally:
|
|
138
|
+
conn.close() # Automatic cleanup
|
|
139
|
+
|
|
140
|
+
@resource
|
|
141
|
+
async def async_http_client() -> AsyncIterator[httpx.AsyncClient]:
|
|
142
|
+
async with httpx.AsyncClient() as client:
|
|
143
|
+
yield client
|
|
144
|
+
# Automatic async cleanup
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 6. Advanced Scoping
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from injectq import Scope
|
|
151
|
+
|
|
152
|
+
# Built-in scopes
|
|
153
|
+
container.bind(AppConfig, scope=Scope.APP) # Application lifetime
|
|
154
|
+
container.bind(RequestContext, scope=Scope.REQUEST) # Per request
|
|
155
|
+
container.bind(ActionContext, scope=Scope.ACTION) # Per action
|
|
156
|
+
container.bind(TempData, scope=Scope.TRANSIENT) # Always new
|
|
157
|
+
|
|
158
|
+
# Custom scopes
|
|
159
|
+
class TaskScope(Scope):
|
|
160
|
+
def enter(self):
|
|
161
|
+
self.task_id = uuid.uuid4()
|
|
162
|
+
|
|
163
|
+
def exit(self):
|
|
164
|
+
# cleanup logic
|
|
165
|
+
pass
|
|
166
|
+
|
|
167
|
+
# Scope management
|
|
168
|
+
async def handle_request():
|
|
169
|
+
async with container.scope(Scope.REQUEST):
|
|
170
|
+
service = container.get(UserService)
|
|
171
|
+
# REQUEST scoped dependencies available
|
|
172
|
+
# Automatic cleanup when exiting scope
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 7. Framework Integrations
|
|
176
|
+
Optional dependency, can be installed via pip like this
|
|
177
|
+
```
|
|
178
|
+
# to install both fastapi and injectq
|
|
179
|
+
pip install injectq[fastapi]
|
|
180
|
+
```
|
|
181
|
+
#### FastAPI Integration
|
|
182
|
+
```python
|
|
183
|
+
from injectq.integrations.fastapi import setup_injectq, Injected
|
|
184
|
+
from fastapi import FastAPI
|
|
185
|
+
|
|
186
|
+
app = FastAPI()
|
|
187
|
+
container = InjectQ([DatabaseModule(), ServiceModule()])
|
|
188
|
+
|
|
189
|
+
@app.get("/users")
|
|
190
|
+
async def get_users(service: Injected[UserService]) -> List[User]:
|
|
191
|
+
return await service.get_all_users()
|
|
192
|
+
|
|
193
|
+
# Automatic scope management per request
|
|
194
|
+
setup_injectq(container, app)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
#### Taskiq Integration
|
|
198
|
+
Taskiq github: https://github.com/taskiq-python/taskiq
|
|
199
|
+
```
|
|
200
|
+
Install Taskiq integration
|
|
201
|
+
```
|
|
202
|
+
pip install injectq[taskiq]
|
|
203
|
+
```
|
|
204
|
+
```python
|
|
205
|
+
from injectq.integrations.taskiq import setup_injectq
|
|
206
|
+
from taskiq import TaskiqBroker
|
|
207
|
+
|
|
208
|
+
broker = TaskiqBroker()
|
|
209
|
+
|
|
210
|
+
@broker.task
|
|
211
|
+
@inject
|
|
212
|
+
async def process_user_data(user_id: int, service: UserService):
|
|
213
|
+
# Dependencies injected into background tasks
|
|
214
|
+
return await service.process(user_id)
|
|
215
|
+
|
|
216
|
+
setup_injectq(container, broker)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
#### FastMCP Integration
|
|
220
|
+
```
|
|
221
|
+
pip install injectq[fastmcp]
|
|
222
|
+
```
|
|
223
|
+
```python
|
|
224
|
+
from injectq.integrations.fastmcp import setup_injectq
|
|
225
|
+
from fastmcp import FastMCP
|
|
226
|
+
|
|
227
|
+
mcp = FastMCP()
|
|
228
|
+
|
|
229
|
+
@mcp.tool()
|
|
230
|
+
@inject
|
|
231
|
+
async def search_users(query: str, service: UserService) -> List[User]:
|
|
232
|
+
# Dependencies injected into MCP tools
|
|
233
|
+
return await service.search(query)
|
|
234
|
+
|
|
235
|
+
setup_injectq(container, mcp)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### 8. Testing Support
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
import pytest
|
|
242
|
+
from injectq.testing import override_dependency
|
|
243
|
+
|
|
244
|
+
def test_user_service():
|
|
245
|
+
# Override dependencies for testing
|
|
246
|
+
mock_db = MockDatabase()
|
|
247
|
+
|
|
248
|
+
with override_dependency(DatabaseConnection, mock_db):
|
|
249
|
+
service = container.get(UserService)
|
|
250
|
+
# service now uses mock_db
|
|
251
|
+
result = service.get_user(1)
|
|
252
|
+
assert result is not None
|
|
253
|
+
|
|
254
|
+
# Pytest integration
|
|
255
|
+
@pytest.fixture
|
|
256
|
+
def test_container():
|
|
257
|
+
with InjectQ.test_mode():
|
|
258
|
+
container = InjectQ()
|
|
259
|
+
container.bind(DatabaseConnection, MockDatabase())
|
|
260
|
+
yield container
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### 9. Component Architecture
|
|
264
|
+
|
|
265
|
+
```python
|
|
266
|
+
from injectq import Component
|
|
267
|
+
|
|
268
|
+
# Define components for modular applications
|
|
269
|
+
auth_component = Component("auth")
|
|
270
|
+
user_component = Component("user")
|
|
271
|
+
order_component = Component("order")
|
|
272
|
+
|
|
273
|
+
# Bind services to specific components
|
|
274
|
+
container.bind(AuthService, component=auth_component)
|
|
275
|
+
container.bind(UserService, component=user_component)
|
|
276
|
+
container.bind(OrderService, component=order_component)
|
|
277
|
+
|
|
278
|
+
# Cross-component dependencies
|
|
279
|
+
container.allow_cross_component(user_component, auth_component)
|
|
280
|
+
|
|
281
|
+
# Component-scoped resolution
|
|
282
|
+
auth_service = container.get(AuthService, component=auth_component)
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### 10. Performance and Diagnostics
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
# Performance monitoring
|
|
289
|
+
from injectq.diagnostics import DependencyProfiler
|
|
290
|
+
|
|
291
|
+
with DependencyProfiler() as profiler:
|
|
292
|
+
service = container.get(UserService)
|
|
293
|
+
|
|
294
|
+
print(profiler.report()) # Dependency resolution timing
|
|
295
|
+
|
|
296
|
+
# Dependency graph visualization
|
|
297
|
+
container.visualize_dependencies() # Generates dependency graph
|
|
298
|
+
|
|
299
|
+
# Validation and early error detection
|
|
300
|
+
container.validate() # Check for circular dependencies, missing bindings
|
|
301
|
+
|
|
302
|
+
# Pre-compilation for production
|
|
303
|
+
container.compile() # Pre-resolve dependency graphs for performance
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Implementation Architecture
|
|
307
|
+
|
|
308
|
+
### Core Modules Structure
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
injectq/
|
|
312
|
+
├── __init__.py # Main exports
|
|
313
|
+
├── core/
|
|
314
|
+
│ ├── container.py # InjectQ main container
|
|
315
|
+
│ ├── registry.py # Service registration
|
|
316
|
+
│ ├── resolver.py # Dependency resolution
|
|
317
|
+
│ ├── scopes.py # Scope management
|
|
318
|
+
│ ├── lifecycle.py # Object lifecycle
|
|
319
|
+
│ ├── components.py # Component isolation
|
|
320
|
+
│ └── resources.py # Resource management
|
|
321
|
+
├── decorators/
|
|
322
|
+
│ ├── inject.py # @inject decorator
|
|
323
|
+
│ ├── singleton.py # @singleton decorator
|
|
324
|
+
│ ├── providers.py # @provider decorator
|
|
325
|
+
│ └── scoped.py # Scoped decorators
|
|
326
|
+
├── modules/
|
|
327
|
+
│ ├── base.py # Module base class
|
|
328
|
+
│ ├── providers.py # Provider patterns
|
|
329
|
+
│ └── configuration.py # Config integration
|
|
330
|
+
├── integrations/
|
|
331
|
+
│ ├── fastapi/ # FastAPI integration
|
|
332
|
+
│ ├── taskiq/ # Taskiq integration
|
|
333
|
+
│ ├── fastmcp/ # FastMCP integration
|
|
334
|
+
│ └── testing/ # Test utilities
|
|
335
|
+
├── diagnostics/
|
|
336
|
+
│ ├── profiling.py # Performance monitoring
|
|
337
|
+
│ ├── validation.py # Dependency validation
|
|
338
|
+
│ └── visualization.py # Graph visualization
|
|
339
|
+
└── utils/
|
|
340
|
+
├── types.py # Type utilities
|
|
341
|
+
├── exceptions.py # Custom exceptions
|
|
342
|
+
└── helpers.py # Helper functions
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## Performance Benchmarks Target
|
|
346
|
+
|
|
347
|
+
```python
|
|
348
|
+
# Target performance goals (operations per second)
|
|
349
|
+
BENCHMARKS = {
|
|
350
|
+
"simple_injection": 1_000_000, # Simple type resolution
|
|
351
|
+
"complex_dependency": 100_000, # Multi-level dependencies
|
|
352
|
+
"scoped_injection": 500_000, # Scoped dependency resolution
|
|
353
|
+
"factory_creation": 250_000, # Factory-based creation
|
|
354
|
+
"async_injection": 200_000, # Async dependency injection
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
# Memory usage targets
|
|
358
|
+
MEMORY_TARGETS = {
|
|
359
|
+
"container_overhead": "< 1MB", # Base container memory
|
|
360
|
+
"per_service_overhead": "< 100 bytes", # Per registered service
|
|
361
|
+
"resolution_overhead": "< 50 bytes", # Per resolution call
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Migration Support
|
|
366
|
+
|
|
367
|
+
### From Kink
|
|
368
|
+
```python
|
|
369
|
+
# Kink code
|
|
370
|
+
from kink import di, inject
|
|
371
|
+
|
|
372
|
+
di["service"] = MyService()
|
|
373
|
+
|
|
374
|
+
@inject
|
|
375
|
+
def handler(service: MyService):
|
|
376
|
+
pass
|
|
377
|
+
|
|
378
|
+
# InjectQ equivalent (seamless migration)
|
|
379
|
+
from injectq import InjectQ, inject
|
|
380
|
+
|
|
381
|
+
container = InjectQ.get_instance()
|
|
382
|
+
container["service"] = MyService()
|
|
383
|
+
|
|
384
|
+
@inject
|
|
385
|
+
def handler(service: MyService):
|
|
386
|
+
pass
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### From Python-Injector
|
|
390
|
+
```python
|
|
391
|
+
# Python-Injector code
|
|
392
|
+
from injector import Injector, inject, Module
|
|
393
|
+
|
|
394
|
+
class MyModule(Module):
|
|
395
|
+
def configure(self, binder):
|
|
396
|
+
binder.bind(Service, ServiceImpl)
|
|
397
|
+
|
|
398
|
+
injector = Injector([MyModule()])
|
|
399
|
+
|
|
400
|
+
# InjectQ equivalent
|
|
401
|
+
from injectq import InjectQ, Module
|
|
402
|
+
|
|
403
|
+
class MyModule(Module):
|
|
404
|
+
def configure(self, binder):
|
|
405
|
+
binder.bind(Service, ServiceImpl)
|
|
406
|
+
|
|
407
|
+
container = InjectQ([MyModule()])
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
## Quality Assurance
|
|
411
|
+
|
|
412
|
+
### Type Safety Requirements
|
|
413
|
+
- Full mypy compliance
|
|
414
|
+
- Generic type support
|
|
415
|
+
- Forward reference resolution
|
|
416
|
+
- Protocol-based injection
|
|
417
|
+
|
|
418
|
+
### Testing Requirements
|
|
419
|
+
- 100% test coverage
|
|
420
|
+
- Property-based testing
|
|
421
|
+
- Performance regression tests
|
|
422
|
+
- Framework integration tests
|
|
423
|
+
|
|
424
|
+
### Documentation Requirements
|
|
425
|
+
- Complete API documentation
|
|
426
|
+
- Migration guides
|
|
427
|
+
- Performance benchmarks
|
|
428
|
+
- Best practices guide
|
|
429
|
+
|
|
430
|
+
## Conclusion
|
|
431
|
+
|
|
432
|
+
InjectQ represents the next generation of Python dependency injection libraries, combining proven patterns with modern performance requirements and developer experience expectations. It provides a clear migration path from existing libraries while offering unique features for modern Python applications.
|
|
433
|
+
|
|
434
|
+
The library is designed to grow with your application: start simple with the dict-like interface, add decorators for convenience, incorporate modules for organization, and leverage advanced features like components and custom scopes for complex applications.
|
injectq-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 InjectQ Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
injectq-0.1.0/Makefile
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Makefile for PyAgenity packaging and publishing
|
|
2
|
+
|
|
3
|
+
.PHONY: build publish testpublish clean test test-cov
|
|
4
|
+
|
|
5
|
+
build:
|
|
6
|
+
uv pip install build
|
|
7
|
+
python -m build
|
|
8
|
+
|
|
9
|
+
publish: build
|
|
10
|
+
uv pip install twine
|
|
11
|
+
twine upload dist/*
|
|
12
|
+
|
|
13
|
+
testpublish: build
|
|
14
|
+
uv pip install twine
|
|
15
|
+
twine upload --repository testpypi dist/*
|
|
16
|
+
|
|
17
|
+
clean:
|
|
18
|
+
rm -rf dist build *.egg-info
|
|
19
|
+
|
|
20
|
+
test:
|
|
21
|
+
uv run pytest -v
|
|
22
|
+
|
|
23
|
+
.PHONY: docs-serve docs-build
|
|
24
|
+
docs-serve:
|
|
25
|
+
@echo "Serving docs at http://127.0.0.1:8000"
|
|
26
|
+
mkdocs serve -a 127.0.0.1:8000
|
|
27
|
+
|
|
28
|
+
docs-build:
|
|
29
|
+
mkdocs build --strict
|
|
30
|
+
|
|
31
|
+
test-cov:
|
|
32
|
+
uv run pytest --cov=pyagenity --cov-report=html --cov-report=term-missing --cov-report=xml -v
|
injectq-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: injectq
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Modern Python dependency injection library combining simplicity, power, and performance
|
|
5
|
+
Project-URL: Homepage, https://github.com/Iamsdt/injectq
|
|
6
|
+
Project-URL: Documentation, https://github.com/Iamsdt/injectq
|
|
7
|
+
Project-URL: Repository, https://github.com/Iamsdt/injectq
|
|
8
|
+
Project-URL: Issues, https://github.com/Iamsdt/injectq/issues
|
|
9
|
+
Author: InjectQ Contributors
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: container,dependency-injection,di,inversion-of-control,ioc
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Requires-Dist: httpx>=0.28.1
|
|
28
|
+
Requires-Dist: taskiq>=0.11.18
|
|
29
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: black>=22.0.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: flake8>=4.0.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: isort>=5.0.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest-cov>=3.0.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: pytest>=6.0.0; extra == 'dev'
|
|
38
|
+
Provides-Extra: fastapi
|
|
39
|
+
Requires-Dist: fastapi>=0.68.0; extra == 'fastapi'
|
|
40
|
+
Provides-Extra: taskiq
|
|
41
|
+
Requires-Dist: taskiq>=0.9.0; extra == 'taskiq'
|
|
42
|
+
Provides-Extra: testing
|
|
43
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'testing'
|
|
44
|
+
Requires-Dist: pytest>=6.0.0; extra == 'testing'
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
# InjectQ
|
|
48
|
+
|
|
49
|
+
A modern Python dependency injection library that combines the simplicity of kink, the power of python-injector, and the advanced features of modern DI frameworks.
|
|
50
|
+
|
|
51
|
+
## Features
|
|
52
|
+
|
|
53
|
+
- **Simplicity First**: Start with simple dict-like interface, grow into advanced features
|
|
54
|
+
- **Multiple API Styles**: Choose between `@inject` decorators and `Inject()` functions
|
|
55
|
+
- **Type Safe**: Full mypy compliance with early error detection
|
|
56
|
+
- **Performance Optimized**: Compile-time dependency resolution with caching
|
|
57
|
+
- **Modern Framework Native**: Built-in support for FastAPI, Taskiq, and FastMCP
|
|
58
|
+
- **Resource Management**: Automatic cleanup and finalization
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from injectq import InjectQ, inject, singleton
|
|
64
|
+
|
|
65
|
+
# Create container
|
|
66
|
+
container = InjectQ.get_instance()
|
|
67
|
+
|
|
68
|
+
# Simple dict-like binding
|
|
69
|
+
container[str] = "Hello, World!"
|
|
70
|
+
|
|
71
|
+
# Class binding
|
|
72
|
+
@singleton
|
|
73
|
+
class UserService:
|
|
74
|
+
def __init__(self, message: str):
|
|
75
|
+
self.message = message
|
|
76
|
+
|
|
77
|
+
def greet(self) -> str:
|
|
78
|
+
return f"Service says: {self.message}"
|
|
79
|
+
|
|
80
|
+
# Automatic dependency injection
|
|
81
|
+
@inject
|
|
82
|
+
def main(service: UserService) -> None:
|
|
83
|
+
print(service.greet())
|
|
84
|
+
|
|
85
|
+
if __name__ == "__main__":
|
|
86
|
+
main() # Prints: Service says: Hello, World!
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Installation
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pip install injectq
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
With optional framework integrations:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pip install injectq[fastapi] # FastAPI integration
|
|
99
|
+
pip install injectq[taskiq] # Taskiq integration
|
|
100
|
+
pip install injectq[fastmcp] # FastMCP integration
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Documentation
|
|
104
|
+
|
|
105
|
+
See the [complete specification](INJECTQ_SPECIFICATION.md) for detailed API documentation and examples.
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
MIT License - see LICENSE file for details.
|