SuperAPI AI 工具集

setting-up-python-libraries

编程与开发

查看项目

更新于 10-16 01:07

技能介绍

用途:帮助搭建专业的 Python 库项目,采用现代工具链,包括 pyproject.toml、uv、ruff、pytest、pre-commit 与 GitHub Actions。适用于创建新 Python 库时快速生成规范结构。

主要能力:提供推荐的项目结构(src/ 布局、py.typed 标记、tests/、pyproject.toml、Makefile、.pre-commit-config.yaml、.github/workflows/ci.yml),并给出 pyproject.toml、CI、Makefile 的模板说明。核心配置示例包含 build-system、project 元数据、可选依赖 dev(pytest、ruff、mypy)及 setuptools 包发现。

使用方式:常用命令包括 uv sync --extra dev、pre-commit install;日常流程为 ruff check src tests、ruff format src tests、pytest、mypy src。可用辅助脚本 python scripts/create_project.py my-library --author "Name" --license MIT 生成项目结构,--license 接受 SPDX 标识符(默认 MIT,MIT 与 BSD-3-Clause 会生成 LICENSE 文件)。

关键约定:本地检查需与 CI 一致;make lint 必须只读、不加 --fix,--fix 仅放在 format 与 pre-commit 钩子中;CI 与 make lint 需同时检查格式(ruff check 与 ruff format --check);Makefile 与 CI 检查相同路径;ruff 配置放在 [tool.ruff.lint],并保持 requires-python 与 target-version 同步;覆盖率建议用 pytest --cov 的终端报告。

限制:资料未提供具体版本兼容性、性能数据或收费信息;部分模板细节需参考 PYPROJECT.md、CI.md、MAKEFILE.md。