checks.structure.StructureCheck

checks.structure.StructureCheck()

Check that the project has an importable package or module.

Accepted layouts:

  • src layout: code in src/<package_name>/
  • flat layout: code directly in the project root
  • a source directory named by the build backend, lib/ or python/
  • a single-file module, a PEP 420 namespace package or a stub-only package

Directories of Rust, C or front-end sources under src/ are ignored. A native-extension project with no Python package is skipped.

Attributes

name :

The check identifier (“structure”).

description :

Human-readable description of this check.

rules :

Every code the check can emit, with what the rule means.

hints :

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

Examples

Run the structure check:

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

Methods

Name Description
run Check package directory structure.

run

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

Check package directory structure.

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 a package, module, namespace package or stub-only package is found
: CheckResult
  • NOTE status if nothing is found and src/ holds sources that no native build explains, or Python files exist only outside a recognized layout
: CheckResult
  • WARNING status if the package directory has no __init__.py
: CheckResult
  • ERROR status if no package or module is found
: CheckResult
  • SKIPPED status (“not-applicable”) if nothing is found in a native-extension project