← 返回
未分类 中文

Pyproject Toml Validator

Validate Python project pyproject.toml files against PEP 517/621 rules for project metadata, build system, and tool configurations with detailed reports.
依据 PEP 517/621 规则校验 pyproject.toml 文件,验证项目元数据、构建系统和工具配置,并提供详细报告。
charlie-morrison
未分类 clawhub v1.0.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 444
下载
💾 1
安装
1
版本
#latest

概述

pyproject-toml-validator

Validate pyproject.toml files for Python projects against PEP 517/621 standards.

What it does

Checks your pyproject.toml for common mistakes across three areas:

  • [project] — name format (PEP 508), version, license (SPDX), classifiers, dependency specs, authors, dynamic fields
  • [build-system] — requires, build-backend validation, known backends
  • [tool.*] — ruff, mypy, pytest, black, isort section validation with tool-specific rules

Rules (30+)

CategoryRulesExamples
--------------------------
Project metadata (10)Missing name/version, invalid name format, unknown fields, malformed requires-python, unknown classifiers, empty authors, name in dynamicname = "My Package!" → invalid PEP 508 name
Dependencies (4)Duplicate deps, unpinned deps, overlapping optional groupsrequests and Requests both listed
Build system (4)Missing requires/build-backend, empty requires, unknown fieldsNo [build-system] table
Tool sections (12+)Ruff select/ignore overlap, mypy type mismatches, black/ruff conflict, isort/ruff conflict, unusual line lengths, invalid target versions[tool.ruff.lint] select = ["E501"] + ignore = ["E501"]

Output formats

  • text — human-readable with severity icons (❌ ⚠️ ℹ️)
  • json — structured with summary counts
  • summary — one-line PASS/WARN/FAIL

Exit codes

  • 0 — no errors (warnings/info allowed)
  • 1 — errors found (or --strict with any issue)
  • 2 — file not found or parse error

Commands

validate

Full validation of all sections.

python3 scripts/pyproject_validator.py validate pyproject.toml
python3 scripts/pyproject_validator.py validate --format json pyproject.toml
python3 scripts/pyproject_validator.py validate --strict pyproject.toml

project

Validate only the [project] table.

python3 scripts/pyproject_validator.py project pyproject.toml

build

Validate only [build-system].

python3 scripts/pyproject_validator.py build pyproject.toml

tools

Validate only [tool.*] sections (ruff, mypy, pytest, black, isort).

python3 scripts/pyproject_validator.py tools --min-severity warning pyproject.toml

Options

OptionValuesDefaultDescription
--------------------------------------
--formattext, json, summarytextOutput format
--min-severityerror, warning, infoinfoFilter by minimum severity
--strictflagoffExit 1 on any issue

Requirements

  • Python 3.11+ (uses tomllib from stdlib)
  • Falls back to built-in simple TOML parser on Python 3.10

Examples

# Quick check
python3 scripts/pyproject_validator.py validate pyproject.toml

# CI pipeline
python3 scripts/pyproject_validator.py validate --strict --format summary pyproject.toml

# Check only tool configs
python3 scripts/pyproject_validator.py tools --format json pyproject.toml

# Filter noise
python3 scripts/pyproject_validator.py validate --min-severity warning pyproject.toml

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-05-03 07:56 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Site Health Monitor

charlie-morrison
监控网站可用性、SSL证书到期、响应时间、HTTP错误和内容变更,生成健康报告并在检测到问题时发送告警。
★ 0 📥 445

Stylelint Config Validator

charlie-morrison
校验 Stylelint 配置文件,检查错误、已弃用规则、配置结构、插件、extends 和 overrides,并输出文本或 JSON 结果。
★ 0 📥 446

Devcontainer Validator

charlie-morrison
在 VS Code 开发容器中验证 devcontainer.json 的语法、结构、功能、端口、生命周期脚本、定制项及安全最佳实践。
★ 0 📥 452