feat: add StorageAdapter abstraction and InMemoryAdapter with full test suite
- Introduce StorageAdapter protocol and InMemoryAdapter (thread-safe, in-memory) in engine/adapter.py to decouple storage from sync logic - Refactor SyncEngine to accept a StorageAdapter, replacing the previous stub that returned an empty list - Wire server to use SyncEngine + InMemoryAdapter, removing hardcoded SYNC_OPERATIONS fixtures - Add tests for engine, adapter, generator, and types (tests/) - Add pre-commit config (.pre-commit-config.yaml) with linting/formatting hooks - Update pyproject.toml and uv.lock with new dev dependencies - Clean up type annotations and CLI help strings across generator, server, and utils
This commit is contained in:
@@ -25,3 +25,74 @@ build-backend = "hatchling.build"
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["src/generator"]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
pythonpath = ["src"]
|
||||
testpaths = ["tests"]
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Black
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
[tool.black]
|
||||
line-length = 88
|
||||
target-version = ["py312"]
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Ruff
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 88
|
||||
target-version = "py312"
|
||||
src = ["src"]
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
"E", # pycodestyle errors
|
||||
"W", # pycodestyle warnings
|
||||
"F", # pyflakes
|
||||
"I", # isort
|
||||
"B", # flake8-bugbear
|
||||
"UP", # pyupgrade
|
||||
"C4", # flake8-comprehensions
|
||||
"SIM", # flake8-simplify
|
||||
"ANN", # flake8-annotations
|
||||
"RUF", # ruff-specific rules
|
||||
]
|
||||
ignore = [
|
||||
"ANN401", # allow Any in some places
|
||||
]
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
known-first-party = ["engine", "server", "client", "generator", "utils"]
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"tests/**" = ["ANN"] # don't require annotations in tests
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Mypy
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
[tool.mypy]
|
||||
python_version = "3.12"
|
||||
mypy_path = "src"
|
||||
strict = true
|
||||
# Pydantic plugin for correct model field inference
|
||||
plugins = ["pydantic.mypy"]
|
||||
|
||||
[tool.pydantic-mypy]
|
||||
init_forbid_extra = true
|
||||
warn_required_dynamic_aliases = true
|
||||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"black>=26.5.1",
|
||||
"mypy>=2.3.1",
|
||||
"pre-commit>=4.6.2",
|
||||
"rope>=1.14.0",
|
||||
"ruff>=0.16.4",
|
||||
]
|
||||
test = [
|
||||
"pytest>=9.1.1",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user