chore: инструменты шаблона — pyproject (ruff, mypy), requirements-dev, Makefile

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Andrey Epifancev 2026-10-03 18:01:18 +04:00
parent b018b6b055
commit bb20d323d0
4 changed files with 83 additions and 50 deletions

40
Makefile Normal file
View File

@ -0,0 +1,40 @@
# Команды разработки arm-core. Backend — api/.venv; запуск из корня репозитория.
VENV := api/.venv
BIN := $(CURDIR)/$(VENV)/bin
COMPOSE_FILE ?= ../docs/dev/docker-compose.yml
.PHONY: venv lint test test-integration check check-full up migrate seed seed-dev
# Python 3.11 (версия платформы); внутренние пакеты raisa_* вне банка недоступны — пропускаем их
venv:
cd api && uv venv --python 3.11 .venv
cd api && grep -v '^raisa_' requirements.txt | uv pip install --python .venv/bin/python -r -
cd api && grep -v '^-r' requirements-dev.txt | uv pip install --python .venv/bin/python -r -
lint:
cd api && $(BIN)/ruff check .
cd api && $(BIN)/ruff format --check .
cd api && $(BIN)/mypy src
test:
cd api && $(BIN)/pytest -m "not integration"
test-integration:
cd api && $(BIN)/pytest -m integration
check: lint test
# TODO (задача 25): добавить фронт (lint/test/build web/), проверку миграций с нуля и откат, актуальность OpenAPI
check-full: check test-integration
up:
docker compose -f $(COMPOSE_FILE) up -d
migrate:
cd api && $(BIN)/alembic upgrade head
seed:
cd api && $(BIN)/python -m scripts.seed
seed-dev:
cd api && $(BIN)/python -m scripts.seed --dev

28
api/pyproject.toml Normal file
View File

@ -0,0 +1,28 @@
# Настройки инструментов качества. Зависимости — в requirements*.txt, pytest — в pytest.ini.
[tool.ruff]
line-length = 120
target-version = "py311"
[tool.ruff.lint]
select = ["E", "F", "I", "UP", "B", "PL"]
[tool.ruff.lint.isort]
known-first-party = ["src", "scripts"]
[tool.mypy]
python_version = "3.11"
strict = false
check_untyped_defs = true
plugins = ["pydantic.mypy"]
mypy_path = "."
explicit_package_bases = true
[[tool.mypy.overrides]]
module = ["src.models.*", "src.domain.*"]
strict = true
# Сторонние пакеты без типов (или недоступные вне банка)
[[tool.mypy.overrides]]
module = ["smbclient.*", "nkeys.*", "miniopy_async.*", "nats.*", "raisa_*", "pydbml.*"]
ignore_missing_imports = true

View File

@ -19,3 +19,6 @@ env =
APP_ENV=test APP_ENV=test
ENV_FILE=.env.test ENV_FILE=.env.test
norecursedirs = .git __pycache__ .venv env build dist norecursedirs = .git __pycache__ .venv env build dist
markers =
integration: тесты, которым нужны PostgreSQL/NATS (docker compose); запускаются отдельно от юнит-тестов
fixtures: тесты на реальных данных из ../fixtures (внутренний доступ)

View File

@ -1,50 +1,12 @@
aiosqlite # Инструменты разработки и проверок. Платформенные зависимости — в requirements.txt (не меняем).
alembic # Нижние границы мажорных версий: воспроизводимо, но без конфликта с пинами платформы.
annotated-types==0.7.0 -r requirements.txt
anyio==4.8.0 ruff>=0.8
argon2-cffi mypy>=1.13
asyncpg pytest>=8.3
certifi==2024.12.14 pytest-asyncio>=0.24
click==8.1.8 pytest-env>=1.1
colorama==0.4.6 pytest-cov>=6.0
dnspython==2.7.0 PyJWT[crypto]>=2.9
email_validator==2.2.0 pydbml>=1.1
et_xmlfile==2.0.0 types-PyYAML>=6.0
fastapi==0.115.7
fastapi-cli==0.0.7
h11==0.14.0
httpcore==1.0.7
httptools==0.6.4
httpx==0.27.2
idna==3.10
itsdangerous==2.2.0
Jinja2==3.1.5
markdown-it-py==3.0.0
MarkupSafe==3.0.2
mdurl==0.1.2
openpyxl==3.1.5
orjson==3.10.15
pydantic==2.10.6
pydantic-extra-types==2.10.2
pydantic-settings==2.7.1
pydantic_core==2.27.2
Pygments==2.19.1
python-dotenv==1.0.1
python-jose
python-multipart==0.0.20
PyYAML==6.0.2
rich==13.9.4
rich-toolkit==0.13.2
shellingham==1.5.4
sniffio==1.3.1
sqlalchemy
starlette==0.45.3
typer==0.15.1
typing_extensions==4.12.2
ujson==5.10.0
uvicorn==0.34.0
watchfiles==1.0.4
websockets==14.2
pytest-asyncio
pytest-env
cosmic-ray