Metadata-Version: 2.1
Name: svcs
Version: 23.10.0
Summary: A Lightweight Service Locator
Project-URL: Changelog, https://github.com/hynek/svcs/blob/main/CHANGELOG.md
Project-URL: Documentation, https://svcs.hynek.me/
Project-URL: Source, https://github.com/hynek/svcs
Project-URL: Funding, https://github.com/sponsors/hynek
Author-email: Hynek Schlawack <hs@ox.cx>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: >=3.8
Requires-Dist: attrs>=21.3.0
Provides-Extra: dev
Requires-Dist: flask; extra == 'dev'
Requires-Dist: pyramid; extra == 'dev'
Requires-Dist: svcs[tests,typing]; extra == 'dev'
Requires-Dist: tox>4; extra == 'dev'
Requires-Dist: webtest; extra == 'dev'
Provides-Extra: docs
Requires-Dist: flask; extra == 'docs'
Requires-Dist: furo; extra == 'docs'
Requires-Dist: myst-parser; extra == 'docs'
Requires-Dist: pytest; extra == 'docs'
Requires-Dist: sphinx; extra == 'docs'
Requires-Dist: sphinx-notfound-page; extra == 'docs'
Requires-Dist: sybil; extra == 'docs'
Provides-Extra: tests
Requires-Dist: pytest; extra == 'tests'
Requires-Dist: pytest-asyncio; extra == 'tests'
Requires-Dist: sybil; extra == 'tests'
Provides-Extra: typing
Requires-Dist: flask; extra == 'typing'
Requires-Dist: mypy>=1.4; extra == 'typing'
Requires-Dist: pyramid; extra == 'typing'
Description-Content-Type: text/markdown

<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 Lightweight Service Locator for Python.</em>
</p>

> **WARNING**
> ☠️ Not ready yet! ☠️
>
> This project is only public to [gather feedback](https://github.com/hynek/svcs/discussions), and everything can and will change until the project is proclaimed stable.
>
> The code has 100% test and type coverage, and the shipped *Flask* and *Pyramid* integrations have been in production for years, but the API details can still change.

<!-- begin index -->

*svcs* (pronounced *services*) is a [**service locator**](https://en.wikipedia.org/wiki/Service_locator_pattern) for Python.
It gives you a central place to register factories for types/interfaces and then imperatively request instances of those types with **automatic cleanup** and **health checks**.

<!-- begin benefits -->
Benefits:

- Eliminates tons of repetitive **boilerplate** code,
- unifies **acquisition** and **cleanups** of resources,
- provides full *static* **type safety** for them,
- simplifies **testing** through **loose coupling**,
- and allows for easy **health checks** across *all* resources.

The goal is to minimize the code for acquiring pluggable resources in your business code to:

```python
def view(request):
    db, api, cache = request.svcs.get(Database, WebAPIClient, Cache)
```

It's ensured that 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`.

<!-- end benefits -->

*svcs* comes with seamless integration for the **Flask** and **Pyramid** web frameworks and has first-class **async** support.

<!-- end index -->
<!-- begin typing -->
While *svcs* 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), if you find that intriguing!


## Project Links

- [**PyPI**](https://pypi.org/project/svcs/)
- [**Source Code**](https://github.com/hynek/svcs)
- [**Documentation**](https://svcs.hynek.me)
- [**Changelog**](https://github.com/hynek/svcs/blob/main/CHANGELOG.md)

## Release Information

### Added

- Proper documentation at <https://svcs.hynek.me/>!
  I guess it's getting serious.
  [#17](https://github.com/hynek/svcs/pull/17)

- Pyramid integration.

  Please note that not all integrations will be shipped with *svcs* proper once it is stable.
  Some will be moved to separate packages and Pyramid is a prime contender for that.


---

[→ 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) locator 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.
