svcs-25.1.0
توضیحات
A Flexible Service Locator
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | svcs-25.1.0 |
| نام | svcs |
| نسخه کتابخانه | 25.1.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | - |
| ایمیل نویسنده | Hynek Schlawack <hs@ox.cx> |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/svcs/ |
| مجوز | - |
<p align="center">
<a href="https://github.com/hynek/svcs/">
<img src="https://raw.githubusercontent.com/hynek/svcs/main/docs/_static/logo_with_name.svg" width="35%" alt="svcs logo showing a hexagon-shaped radar"" />
</a>
</p>
<p align="center">
<em>A Flexible Service Locator for Python.</em>
</p>
<!-- begin index -->
*svcs* (pronounced *services*) is a **dependency container** for Python.
It gives you a central place to register factories for types/interfaces and then imperatively acquire instances of those types with **automatic cleanup** and **health checks**.
It's suitable for implementing [Inversion of Control](https://svcs.hynek.me/en/latest/glossary.html#term-Inversion-of-Control) using either **dependency injection** or **service location** while not requiring global state, decorators, or mangling of function signatures.
<!-- begin benefits -->
Benefits:
- Eliminates tons of repetitive **boilerplate** code,
- unifies **acquisition** and **cleanups** of services,
- provides full *static* **type safety** for them,
- simplifies **testing** through **loose coupling**,
- improves *live* **introspection** and **monitoring** with **health checks**.
The goal is to minimize the code for acquiring pluggable services to:
<!-- end index -->
<!-- end benefits -->
<!-- skip: next -->
```python
from svcs.your_framework import svcs_from
def view(request):
db, api, cache = svcs_from(request).get(Database, WebAPIClient, Cache)
```
... or less!
<!-- begin addendum -->
To a type checker like [Mypy](https://mypy-lang.org), `db` has the type `Database`, `api` has the type `WebAPIClient`, and `cache` has the type `Cache`.
`db`, `api`, and `cache` will be automatically cleaned up when the request ends -- it's context managers all the way down.
<!-- end addendum -->
*svcs* comes with seamless integration for **AIOHTTP**, **FastAPI**, **Flask**, **Pyramid**, and **Starlette**.
<!-- begin typing -->
While *svcs* also has first-class support for static typing, it is **strictly optional** and will always remain so.
*svcs* also doesn't check your types at runtime.
It only forwards the type you have asked for to the type checker.
If you don't use a type checker, that information is ignored without any runtime overhead.
<!-- end typing -->
Read on in [*Why?*](https://svcs.hynek.me/en/latest/why.html) or watch this short video if you're intrigued:
[](https://youtu.be/d1elMD9WgpA)
## Project Links
- [**PyPI**](https://pypi.org/project/svcs/)
- [**GitHub**](https://github.com/hynek/svcs)
- [**Documentation**](https://svcs.hynek.me)
- [**Changelog**](https://github.com/hynek/svcs/blob/main/CHANGELOG.md)
- [**Funding**](https://hynek.me/say-thanks/)
- [**Third-party extensions**](https://github.com/hynek/svcs/wiki/Third%E2%80%90party-Extensions)
## Release Information
### Added
- Python 3.13 support.
- `svcs.Registry` now implements a `__iter__` method that allows to iterate over its registered services.
[#106](https://github.com/hynek/svcs/pull/106)
### Removed
- Python 3.8 support.
### Changed
- Flask: The registry is now stored on `app.extensions`, not `app.config`.
This is an implementation detail.
If you are directly accessing the registry via `app.config`, this is a breaking change, though you should ideally move to `svcs.flask.registry` anyway.
[#71](https://github.com/hynek/svcs/discussions/71)
[#72](https://github.com/hynek/svcs/issues/72)
[#73](https://github.com/hynek/svcs/pull/73)
- `Registry.register_factory()` is now more lenient regarding the arguments of the factory.
It only looks at the first argument (if present) and ignores the rest.
[#110](https://github.com/hynek/svcs/pull/110)
### Fixed
- `Container.aget()` now also enters and exits synchronous context managers.
[#93](https://github.com/hynek/svcs/pull/93)
- `Container.aget()` now also enters and exits context managers that are returned by async factories.
[#105](https://github.com/hynek/svcs/pull/105)
---
[Full Changelog →](https://github.com/hynek/svcs/blob/main/CHANGELOG.md)
## Credits
*svcs* is written by [Hynek Schlawack](https://hynek.me/) and distributed under the terms of the [MIT](https://github.com/hynek/svcs/blob/main/LICENSE) license.
The development is kindly supported by my employer [Variomedia AG](https://www.variomedia.de/) and all my fabulous [GitHub Sponsors](https://github.com/sponsors/hynek).
The [Bestagon](https://www.youtube.com/watch?v=thOifuHs6eY) radar logo is made by [Lynn Root](https://www.roguelynn.com), based on an [Font Awesome](https://fontawesome.com) icon.
*svcs* has started out as a wrapper around [*wired*](https://wired.readthedocs.io/) by [Michael Merickel](https://michael.merickel.org/) and has been heavily influenced by it.
نیازمندی
| مقدار | نام |
|---|---|
| - | attrs>=21.3.0 |
| xtr | aiohttp; |
| xtr | fastapi; |
| xtr | flask; |
| xtr | httpx; |
| xtr | mypy>=1.4; |
| xtr | pyramid; |
| xtr | pytest; |
| xtr | pytest-asyncio; |
| xtr | starlette; |
| xtr | sybil>=6; |
| xtr | tox-uv; |
| xtr | tox>4; |
| xtr | aiohttp; |
| xtr | fastapi; |
| xtr | flask; |
| xtr | furo>=2023.8.17; |
| xtr | httpx; |
| xtr | myst-parser; |
| xtr | pyramid; |
| xtr | pytest; |
| xtr | pytest-asyncio; |
| xtr | sphinx-copybutton; |
| xtr | sphinx-design; |
| xtr | sphinx-notfound-page; |
| xtr | sphinx>=7.2.2; |
| xtr | sphinxext-opengraph; |
| xtr | sqlalchemy; |
| xtr | starlette; |
| xtr | sybil; |
| xtr | pytest; |
| xtr | pytest-asyncio; |
| xtr | sybil>=6; |
| xtr | aiohttp; |
| xtr | fastapi; |
| xtr | flask; |
| xtr | mypy>=1.4; |
| xtr | pyramid; |
| xtr | starlette; |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.9 | Python |
نحوه نصب
نصب پکیج whl svcs-25.1.0:
pip install svcs-25.1.0.whl
نصب پکیج tar.gz svcs-25.1.0:
pip install svcs-25.1.0.tar.gz