checks.structure.StructureCheck

checks.structure.StructureCheck()

Check that package has a valid directory structure.

Validates that the package follows one of the standard Python package layouts:

  • src layout: Package code in src/<package_name>/
  • flat layout: Package code directly in project root

The check verifies that package directories contain __init__.py files and are properly structured.

Attributes

name :

The check identifier (“structure”).

description :

Human-readable description of this check.

Examples

Run the structure check:

>>> from pathlib import Path
>>> check = StructureCheck()
>>> result = check.run(Path("."), {"enabled": True})
>>> result.name
'structure'

Check a package with src layout:

>>> # For a package with src/mypackage/__init__.py
>>> # result.status == CheckStatus.OK
>>> # result.details contains "Using src layout"

Methods

Name Description
run Check package directory structure.

run

checks.structure.StructureCheck.run(package_path, config)

Check package directory structure.

Determines the layout type (src or flat) and validates that the package directories are properly formed with __init__.py files.

Parameters

package_path : Path

Path to the package directory to check.

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 valid src or flat layout found
: CheckResult
  • WARNING status if packages missing __init__.py
: CheckResult
  • ERROR status if no package or module found