skillfed

svcs

A Flexible Service Locator

svcs v26.1.0 7.4M downloads/30d#1,741 on PyPI422
Permissive license MIT Active released

What it is and what it does

svcs is a dependency container that centralizes the registration and acquisition of service instances in Python applications. It supports both dependency injection and service locator patterns without requiring global state, decorators, or function signature changes. The container automatically manages cleanup of acquired services through context managers and provides health checks for monitoring.

The package integrates with popular web frameworks (AIOHTTP, FastAPI, Flask, Pyramid, Starlette) and provides full static type safety when used with a type checker. It reduces boilerplate code for service acquisition and cleanup while maintaining loose coupling between components, which simplifies testing. Recent versions added support for abstract types via PEP 747 and autowiring based on type annotations.

Use it for:

  • Manage database connections, API clients, and caches in FastAPI or Flask applications with automatic cleanup per request.
  • Implement dependency injection in web frameworks without decorators or global state, improving testability.
  • Register multiple implementations of a service interface and switch between them for different environments or test scenarios.
  • Add health checks to services for monitoring and observability in production applications.
  • Automatically resolve and inject dependencies based on type annotations in function signatures.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

svcs is a dependency container that registers factories for types and provides automatic cleanup and health checks when acquiring service instances in Python applications.

Yes. svcs is actively maintained, production-stable, has no known vulnerabilities, and solves a genuine problem in dependency management for Python web applications. The low install friction and optional static typing make it accessible. It's particularly valuable if you're using FastAPI, Flask, or another supported framework and want to reduce boilerplate around service acquisition and cleanup.

Install

svcs on PyPI

pip

pip install svcs

uv

uv add svcs

poetry

poetry add svcs

Installing svcs

Before you install

Low friction install with only two lightweight runtime dependencies (attrs and typing-extensions). Active maintenance with a release 32 days ago and recent commits; marked Production/Stable.

License in practice

MIT license permits commercial and private use with minimal restrictions; suitable for most projects.

Quickstart

pip install svcs

from svcs import Container
from attrs import define

@define
class Database:
    pass

container = Container()
container.register(Database, factory=Database)
db = container.get(Database)

Requires Python 3.10 or later; Python 3.9 support was removed.

Verify before relying

  • Whether the framework integrations (AIOHTTP, FastAPI, Flask, Pyramid, Starlette) are included in the base package or require separate installation.
  • Performance characteristics when managing large numbers of service instances or complex dependency graphs.
  • Whether health checks are automatically invoked or must be explicitly called.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 2 — attrs, typing-extensions
Maintenance actively maintained — 32 days since the last release
Last repo commit
First released
Downloads 7,427,821/month — #1,741 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: svcs-26.1.0-py3-none-any.whl

Keywords: aiohttp, dependency injection, fastapi, flask, inversion of control, pyramid, service locator, starlette

Development Status :: 5 - Production/StableProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Typing :: Typed

Tags

dependency injection containerservice locator pythoninversion of controldependency management frameworkautomatic resource cleanuptype-safe service registryfastapi flask dependency injection
dependency-injectioninversion-of-controlweb-framework-integration

More Application Frameworks packages