← 返回
未分类 中文

Requirements Checker

Validate, lint, and sort Python requirements.txt files for best practices and CI.
验证、整理并排序 Python requirements.txt 文件,符合最佳实践并适配 CI。
charlie-morrison charlie-morrison 来源
未分类 clawhub v1.0.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 378
下载
💾 1
安装
1
版本
#latest

概述

requirements-checker

Validate, lint, sort, and compare Python requirements.txt files. Pure stdlib — no external dependencies required.

Validate

Check a requirements file for format errors, invalid specifiers, duplicates, and problematic patterns.

python3 scripts/requirements-checker.py validate requirements.txt

# JSON output for automation
python3 scripts/requirements-checker.py validate requirements.txt --format json

# Strict mode — exit 1 on any issue (CI)
python3 scripts/requirements-checker.py validate requirements.txt --strict

Lint

All validation checks plus best-practice rules: unpinned deps, missing upper bounds, VCS deps, non-alphabetical order, mixed operator styles.

python3 scripts/requirements-checker.py lint requirements.txt

# Markdown output (for PR comments, reports)
python3 scripts/requirements-checker.py lint requirements.txt --format markdown

# Strict mode — exit 1 on warnings too
python3 scripts/requirements-checker.py lint requirements.txt --strict

# Ignore specific rules
python3 scripts/requirements-checker.py lint requirements.txt --ignore unpinned --ignore no-upper-bound

Duplicates

Find packages listed more than once (case-insensitive, PEP 503 normalised).

python3 scripts/requirements-checker.py duplicates requirements.txt

python3 scripts/requirements-checker.py duplicates requirements.txt --format json

Sort

Sort requirements alphabetically. By default writes to stdout; use --write to update the file in-place.

# Preview sorted output
python3 scripts/requirements-checker.py sort requirements.txt

# Write sorted file in-place
python3 scripts/requirements-checker.py sort requirements.txt --write

Compare

Diff two requirements files — shows added, removed, and changed packages with version changes.

python3 scripts/requirements-checker.py compare requirements.txt requirements-new.txt

python3 scripts/requirements-checker.py compare base.txt updated.txt --format markdown

Global Options

OptionDescription
---------------------
`--format text\json\markdown`Output format (default: text)
--strictExit code 1 on any issue, including warnings/info (CI mode)
--ignore RULEIgnore a named rule; repeatable

Validation Checks

RuleSeverityDescription
-----------------------------
invalid-formaterrorLine doesn't match PEP 508
invalid-specifiererrorUnknown operator or unparseable version spec
duplicate-packageerrorSame package name appears more than once
editable-installwarning-e editable installs in production requirements
vcs-dependencywarninggit+, hg+, svn+, bzr+ URL dependencies
custom-index-urlwarning--index-url / --extra-index-url present
url-dependencyinfoDirect URL dependencies
requirement-includeinfo-r nested includes
trailing-whitespaceinfoLine has trailing spaces or tabs
whitespace-only-lineinfoLine contains only whitespace
missing-final-newlineinfoFile doesn't end with newline

Lint Rules (in addition to validation)

RuleSeverityDescription
-----------------------------
unpinnedwarningDependency has no version specifier
no-upper-boundwarning>= used without a < / <= upper bound
non-alphabeticalwarningPackages are not in alphabetical order
mixed-operatorsinfoFile mixes == exact pins and >= range specifiers

Example Output

File: requirements.txt
  [ERROR] line 4  (duplicate-package)  Duplicate package 'requests' (first seen on line 2)
           requests==2.31.0
  [WARNING] line 7  (no-upper-bound)  'django' uses >= without an upper bound
           django>=4.0
  [WARNING] line 1  (non-alphabetical)  'zope' is out of alphabetical order
           zope==5.0

Summary: 3 issue(s) — 1 error(s), 2 warning(s), 0 info(s)

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-05-07 09:29 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 686 📥 330,816
dev-programming

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 80 📥 182,941
ai-agent

Slack Messaging

charlie-morrison
Slack 消息—通过 CLI 和 API 发送消息、管理频道、上传文件、添加反应并自动化团队通知。
★ 0 📥 549