Python开发包,简化开发
项目描述
calcipy
calcipy
是一个Python包,实现了代码风格(linting、自动修复)、文档、CI/CD和日志记录等最佳实践。就像硬珊瑚中的碳酸钙一样,包可以建立在 calcipy
基础之上。
calcipy
有一些可配置性,但专为我的特定用例量身定制。如果您想要类似的功能,可以考虑许多替代方案
- pyscaffold 是一个更加成熟的项目,旨在实现相同的目标,但采用了略微不同的方法和技术栈(tox vs. nox、cookiecutter vs. copier等)
- tidypy、pylama 和 codecheck 提供了类似的功能,即捆绑和运行静态检查器,但假设更少
- pytoil 是一个通用的CLI开发自动化工具
- 还有许多类似工具,例如 pyta、prospector、wemake-python-styleguide / cjolowicz/cookiecutter-hypermodern-python、formate、johnthagen/python-blueprint、oxsecurity/megalinter 等。
安装
Calcipy 需要一些使用 copier 和模板项目管理的静态文件:kyleking/calcipy_template
您可以使用模板快速创建新项目或将 calcipy 添加到现有项目中
# Install copier. pipx is recommended
pipx install copier
# To create a new project
copier copy gh:KyleKing/calcipy_template new_project
cd new_project
# Or convert/update an existing one
cd my_project
copier copy gh:KyleKing/calcipy_template .
copier update
Calcipy 命令行界面 (CLI)
此外,calcipy
可以作为一个 CLI 应用程序运行,而无需将其作为依赖项添加。
快速入门
# For the CLI, only install a few of the extras which can be used from a few different CLI commands
pipx install 'calcipy[lint,tags]'
# Use 'tags' to create a CODE_TAG_SUMMARY of the specified directory
calcipy-tags tags --help
calcipy-tags tags --base-dir=~/path/to/my_project
# You can list all provided CLI commands with
pipx list
venvs are in ~/.local/pipx/venvs
apps are exposed on your $PATH at ~/.local/bin
package calcipy 1.4.0, installed using Python 3.11.4
- calcipy
- calcipy-lint
- calcipy-pack
- calcipy-tags
- calcipy-types
注意:以下 CLI 输出已压缩以提高可读性,但您可以在本地尝试运行这些命令以查看最新的文档和完整选项集。每个后续命令的“用法”、“核心选项”和“全局任务选项”都是相同的,因此为简洁起见,省略了这些内容。
> calcipy-lint
Usage: calcipy-lint [--core-opts] <subcommand> [--subcommand-opts] ...
Core options:
--complete Print tab-completion candidates for given parse remainder.
--hide=STRING Set default value of run()'s 'hide' kwarg.
--print-completion-script=STRING Print the tab-completion script for your preferred shell (bash|zsh|fish).
--prompt-for-sudo-password Prompt user at start of session for the sudo.password config value.
--write-pyc Enable creation of .pyc files.
-d, --debug Enable debug output.
-D INT, --list-depth=INT When listing tasks, only show the first INT levels.
-e, --echo Echo executed commands before running.
-f STRING, --config=STRING Runtime configuration file to use.
-F STRING, --list-format=STRING Change the display format used when listing tasks. Should be one of: flat (default), nested, json.
-h [STRING], --help[=STRING] Show core or per-task help and exit.
-l [STRING], --list[=STRING] List available tasks, optionally limited to a namespace.
-p, --pty Use a pty when executing shell commands.
-R, --dry Echo commands instead of running.
-T INT, --command-timeout=INT Specify a global command execution timeout, in seconds.
-V, --version Show version and exit.
-w, --warn-only Warn, instead of failing, when shell commands fail.
Subcommands:
lint.autopep8 Run autopep8.
lint.check (lint) Run ruff as check-only.
lint.fix Run ruff and apply fixes.
lint.pre-commit Run pre-commit.
lint.pylint Run pylint.
lint.security Attempt to identify possible security vulnerabilities.
lint.watch Run ruff as check-only.
Global Task Options:
*file_args List of Paths available globally to all tasks. Will resolve paths with working_dir
--keep-going Continue running tasks even on failure
--working_dir=STRING Set the cwd for the program. Example: "../run --working-dir .. lint test"
-v,-vv,-vvv Globally configure logger verbosity (-vvv for most verbose)
> calcipy-pack
Subcommands:
pack.check-licenses Check licenses for compatibility with `licensecheck`.
pack.install-extras Run poetry install with all extras.
pack.lock Ensure poetry.lock is up-to-date.
pack.publish Build the distributed format(s) and publish.
> calcipy-tags
Subcommands:
tags.collect-code-tags (tags) Create a `CODE_TAG_SUMMARY.md` with a table for TODO- and FIXME-style code comments.
> calcipy-types
Subcommands:
types.basedpyright Run basedpyright.
types.mypy Run mypy.
types.pyright Run pyright.
Calcipy 预提交 (Pre-Commit)
calcipy
还可以作为一个 pre-commit
任务使用,只需将以下片段添加到您的 pre-commit
文件中即可
repos:
- repo: https://github.com/KyleKing/calcipy
rev: main
hooks:
- id: tags
- id: lint-fix
- id: types
项目状态
请参阅 Open Issues
和/或 CODE_TAG_SUMMARY。有关发行历史,请参阅 CHANGELOG。
贡献
我们欢迎拉取请求!为了使您的拉取请求顺利接受,我们建议您首先在 GitHub 上打开一个问题来讨论您的想法。有关如何开始使用代码库的资源,请参阅以下文档
行为准则
我们遵循 Contributor Covenant 行为准则。
开源状态
我们尽力合理满足“OpenSSF scorecard”的各个方面,来自 Open Source Insights。
负责任地披露
如果您有任何安全问题需要报告,请私下联系项目维护者。您可以通过 dev.act.kyle@gmail.com 联系我们。
许可证
项目详情
下载文件
下载适用于您平台的应用文件。如果您不确定选择哪一个,请了解更多关于安装包的信息。