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.

REQUIRED_FIELDS :

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

RECOMMENDED_FIELDS :

List of fields that should be present.

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 and recommended fields present
: CheckResult
  • NOTE status if required fields present but some recommended missing
: CheckResult
  • WARNING status if using legacy setup.py/setup.cfg
: CheckResult
  • ERROR status if pyproject.toml is invalid or missing required fields