servicePhilosophy
A small typed foundation for factory-aware repository-style components.
| Python | 3.12+ |
| Runtime deps | none |
| License | MIT |
Core idea
ServiceRepository[FactoryT]
= a neutral base class for objects that need factory access.
It does not require a model.
It does not know about SQL, HTTP, controllers, or frameworks.
ServiceRepository stores an optional factory and exposes it through:
factory— returns the factory, or raisesFactoryRequiredErrorwhen missingmaybe_factory— returns the factory orNonehas_factory—Truewhen a factory was provided at construction
Use ServiceRepositoryProtocol when you want to type against that shape without inheriting from the base class. Use RepositoryFactoryProtocol as a minimal marker for factory types that downstream packages extend.
What this is (and is not)
ServiceRepositoryis not a SQL repository.ServiceRepositoryis not an API client.- It is a shared factory-aware base.
- sqlPhilosophy can extend it with model-bound persistence.
- apiPhilosophy can extend it with HTTP/resource clients.
- Application service repositories can extend it directly for business logic with no model at all.
This package has zero runtime dependencies. It does not include SQLAlchemy, HTTP clients, FastAPI, Pydantic, or Django.
Basic service repository
from servicephilosophy import ServiceRepository
class ServiceFactory:
def greeting(self) -> str:
return "hello"
class GreetingService(ServiceRepository[ServiceFactory]):
def greet(self) -> str:
return self.factory.greeting()
SQL specialization in another package
from typing import Generic, TypeVar
from servicephilosophy import ServiceRepository
ModelT = TypeVar("ModelT")
FactoryT = TypeVar("FactoryT")
class BaseRepository(ServiceRepository[FactoryT], Generic[ModelT, FactoryT]):
model: type[ModelT]
API specialization in another package
from typing import Generic, TypeVar
from servicephilosophy import ServiceRepository
ResourceT = TypeVar("ResourceT")
FactoryT = TypeVar("FactoryT")
class BaseApiRepository(ServiceRepository[FactoryT], Generic[ResourceT, FactoryT]):
pass
Business logic with no model
from servicephilosophy import ServiceRepository
class PermissionServiceRepository(ServiceRepository[ServiceFactory]):
def has_permission(self, actor_id: int, permission: str) -> bool:
return True
Recommended ecosystem
servicePhilosophy
ServiceRepository[FactoryT]
sqlPhilosophy
BaseRepository[ModelT, FactoryT]
apiPhilosophy
BaseApiRepository[ResourceT, FactoryT]
application
PermissionServiceRepository(ServiceRepository[ServiceFactory])
Each layer adds its own concern. servicePhilosophy only handles factory wiring; specialization lives in the package or application that needs it.
Install
pip install servicephilosophy
Development:
uv sync --extra dev
uv run pytest
uv run ruff check src tests
uv run mypy src
Public API
from servicephilosophy import (
FactoryRequiredError,
RepositoryFactoryProtocol,
ServiceRepository,
ServiceRepositoryProtocol,
)
Or import from submodules:
from servicephilosophy.repository import ServiceRepository
from servicephilosophy.protocols import RepositoryFactoryProtocol, ServiceRepositoryProtocol
from servicephilosophy.exceptions import FactoryRequiredError
Metadata
Release files for servicephilosophy 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| servicephilosophy-0.1.1.tar.gz | 5.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| servicephilosophy-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.1 kB
Release files / servicephilosophy-0.1.1.tar.gz
| Download URL | servicephilosophy-0.1.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b6b18ec560a2ef8bb9656e3e5fd8f495e318a1b0b13768bc07d68b8277fbd31
|
|
BLAKE2b-256 checksum How to use checksums |
121042aa9a6a62bb45b5ab587eac0689d9d4ae2e04cd9735935822f21370f4d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.0
|
Release files / servicephilosophy-0.1.1-py3-none-any.whl
| Download URL | servicephilosophy-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a7fbc5f17b68ce1b0f3e86c5b0b80c48aa75be7628cd1ed686092064db56fd95
|
|
BLAKE2b-256 checksum How to use checksums |
0f3313d7e2dee59ecc4fb7ef410b2f41e1f98269d30f831738251567b6268015
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.0
|
Security for servicephilosophy 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.