MT002: HasProjectVersion
Overview
| Property | Value |
|---|---|
| ID | MT002 |
| Name | HasProjectVersion |
| Group | metadata |
| Severity | ERROR |
Description
Checks that the [project].version field is defined in pyproject.toml.
The version is essential for:
- Package releases
- Dependency resolution
- User expectations about compatibility
What it checks
The check verifies that pyproject.toml contains:
[project]
version = "0.1.0"Or uses dynamic versioning:
[project]
dynamic = ["version"]How to fix
Add the version field to your pyproject.toml:
[project]
version = "0.1.0"Versioning schemes
Follow Semantic Versioning:
MAJOR.MINOR.PATCH(e.g.,1.2.3)MAJOR- Breaking changesMINOR- New features (backwards compatible)PATCH- Bug fixes (backwards compatible)
Pre-release versions
version = "1.0.0a1" # Alpha
version = "1.0.0b1" # Beta
version = "1.0.0rc1" # Release candidateDynamic versioning
Some build backends support reading version from other sources:
[project]
dynamic = ["version"]
[tool.hatch.version]
path = "src/my_package/__init__.py"Configuration
Skip this check
[tool.pycmdcheck]
skip = ["MT002"]CLI
pycmdcheck --skip MT002