MT014: ConsistentVersioning
Overview
| Property | Value |
|---|---|
| ID | MT014 |
| Name | ConsistentVersioning |
| Group | metadata |
| Severity | ERROR |
Description
Checks that the version in pyproject.toml matches the __version__ variable in your package’s __init__.py.
Consistent versioning is critical for:
- Users knowing which version they have installed
- Build tools creating correct distribution files
- Dependency resolution working correctly
What it checks
The check compares the version from two sources:
- The
[project].versionfield inpyproject.toml:
[project]
name = "my-package"
version = "1.2.3"- The
__version__variable in__init__.py:
__version__ = "1.2.3"The check looks for __init__.py in these locations:
src/<package_name>/__init__.py(src layout)<package_name>/__init__.py(flat layout)
How to fix
Ensure both version definitions match exactly:
Option 1: Manual synchronization
Update both files when releasing:
# pyproject.toml
[project]
version = "1.2.3"# src/my_package/__init__.py
__version__ = "1.2.3"Option 2: Single source of truth
Use dynamic versioning to read from __init__.py:
[project]
dynamic = ["version"]
[tool.setuptools.dynamic]
version = {attr = "my_package.__version__"}Option 3: Use a version management tool
Tools like bump2version, tbump, or python-semantic-release can update both locations automatically.
Configuration
Skip this check
[tool.pycmdcheck]
skip = ["MT014"]CLI
pycmdcheck --skip MT014