chore: 搭建项目骨架

- pyproject:hatchling + src 布局,核心依赖 psycopg/pydantic/pyyaml/cel-python
- FastAPI 归入 [api] 可选依赖,开发依赖走 PEP 735 dependency-groups
- 建立分层目录:ontology/compiler/storage/repository/graph/timeseries/expr/rules/api
- errors.py 统一异常基类;py.typed 标记类型完整
- ruff(100) + pytest 配置;冒烟测试校验核心包不引入 fastapi/uvicorn
This commit is contained in:
Donny committed 2026-11-05 02:18:10 +08:00
1 parent ecd5925b2c
commit ace505cc6b
16 files changed
+1544 -11

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
[project]
name = "adapter-python-pg"
version = "0.1.0"
description = "基于 ontology 数据基座的 PostgreSQL 中间层适配器(FastAPI 项目以 pip 包引用)"
readme = "README.md"
requires-python = ">=3.11"
license = { text = "Proprietary" }
dependencies = [
"psycopg[binary,pool]>=3.2",
"pydantic>=2.9",
"pydantic-settings>=2.6",
"pyyaml>=6.0.2",
"cel-python>=0.2",
]
[project.optional-dependencies]
# FastAPI 只是可选依赖:核心包不 import 它,宿主项目才需要
api = ["fastapi>=0.115"]
# 开发依赖走 PEP 735 依赖组:uv sync 默认安装,不需要 --extra dev
[dependency-groups]
dev = [
"pytest>=8.0",
"pytest-asyncio>=0.24",
"testcontainers[postgres]>=4.8",
"ruff>=0.8",
"mypy>=1.13",
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src/adapter_python_pg"]
[tool.uv]
package = true
[tool.ruff]
line-length = 100
target-version = "py311"
src = ["src", "tests"]
[tool.ruff.lint]
select = ["E", "F", "I", "UP", "B", "SIM", "RUF"]
# E501: 行宽交给 formatter
# RUF001/002/003: 中文文档与注释里的全角标点是刻意的,不视为歧义字符
ignore = ["E501", "RUF001", "RUF002", "RUF003"]
[tool.pytest.ini_options]
testpaths = ["tests"]
pythonpath = ["src"]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
markers = [
"integration: 需要真实 PostgreSQL 的测试(testcontainers)",
]
[tool.mypy]
python_version = "3.11"
files = ["src"]
strict = true
warn_unused_ignores = true
disallow_untyped_defs = true