punq:适用于Python 3.6+的IoC容器

时间:2021-05-14 12:50:14
【文件属性】:
文件名称:punq:适用于Python 3.6+的IoC容器
文件大小:26KB
文件格式:ZIP
更新时间:2021-05-14 12:50:14
Python 庞克 一个用于现代Python中的依赖项注入的非侵入式库。 受启发,Punq是一个您可以理解的依赖项注入库。 没有全局状态 没有装饰 没有奇怪的语法应用于参数 小型简单的代码库,具有100%的测试覆盖率和对开发人员友好的注释。 安装 Punq。 pip install punq 有关文档,请参见。 快速开始 Punq避免使用全局状态,因此您必须在应用程序的入口点显式创建一个容器: import punq container = punq . Container () 有了容器后,就可以注册应用程序的依赖项。 在最简单的情况下,我们可以使用某个键来注册任意对象: container . register ( "connection_string" , "postgresql://..." ) 然后,我们可以从容器中请求该对象: conn_str = container . r
【文件预览】:
punq-master
----MANIFEST.in(11B)
----.travis.yml(938B)
----README.rst(4KB)
----.coveragerc(84B)
----docs()
--------make.bat(791B)
--------Makefile(613B)
--------source()
----punq()
--------__init__.py(15KB)
--------_compat.py(517B)
----CHANGES.rst(2KB)
----Pipfile(336B)
----tests()
--------test_dependencies.py(1KB)
--------test_string_annotations.py(2KB)
--------test_list_resolution.py(934B)
--------doctest_namespace.py(485B)
--------__init__.py(0B)
--------test_instance_creation.py(6KB)
--------test_chain_dependencies.py(2KB)
----LICENSE(1KB)
----Pipfile.lock(18KB)
----setup.py(1KB)
----.gitignore(1KB)
----Makefile(360B)

网友评论