checks.metadata.MetadataCheck

checks.metadata.MetadataCheck()

Check that package metadata is valid and complete.

Validates package metadata according to PEP 621 (pyproject.toml). Checks for required fields (name, version) and recommends additional fields (description, readme, license, requires-python).

Attributes

name :

The check identifier (“metadata”).

description :

Human-readable description of this check.

rules :

The codes of the findings, each with what the rule means.

hints :

The same codes, each with what to do about the finding.

REQUIRED_FIELDS :

List of fields that must be present in [project].

RECOMMENDED_FIELDS :

List of fields that should be present.

EXTENDED_FIELDS :

List of extended fields checked for completeness.

Examples

Run the metadata check on a package:

>>> from pathlib import Path
>>> check = MetadataCheck()
>>> result = check.run(Path("."), {"enabled": True})
>>> result.status in [CheckStatus.OK, CheckStatus.NOTE, CheckStatus.ERROR]
True

The check validates pyproject.toml structure:

>>> check.REQUIRED_FIELDS
['name', 'version']

Methods

Name Description
run Check package metadata for validity and completeness.

run

checks.metadata.MetadataCheck.run(package_path, config)

Check package metadata for validity and completeness.

Looks for pyproject.toml first (preferred), falling back to setup.py/setup.cfg (legacy). Validates required fields and suggests recommended fields.

Parameters

package_path : Path

Path to the package directory containing pyproject.toml or setup files.

config : dict[str, Any]

Configuration dictionary for this check. Currently no check-specific options are used.

Returns

: CheckResult

A CheckResult with:

: CheckResult
  • OK status if all required, recommended, and extended (authors, urls, classifiers) fields are present and well formed
: CheckResult
  • NOTE status if recommended or extended fields are missing, a value is not valid, or the metadata is in another backend’s own table or file
: CheckResult
  • WARNING status if the metadata is in setup.py/setup.cfg, or a setuptools project lists a license expression and a License classifier
: CheckResult
  • ERROR status if pyproject.toml cannot be read, required fields are missing, or no metadata is found
: CheckResult

The status is that of the most severe finding.