Skip to main content

Architecture-as-Code checks for Python projects.

Project description

klint

Architecture-as-Code checks for Python projects.

klint enforces architecture rules from a small klint.yaml file. Use it to keep module boundaries explicit, block risky patterns in specific layers, and pin important symbols to their intended owner file.

It installs as a Python package and runs as a native executable:

pip install klint
klint

For machine-readable output:

klint --json
python -m klint --json

By default, klint looks for klint.yaml or klint.config.json in the current working directory. Use --config when the config lives somewhere else:

klint --config path/to/project

CLI

The Python package exposes both a console command and a module entrypoint:

klint
python -m klint

Supported options:

Option Description
--config <dir> Directory containing klint.yaml or klint.config.json. Defaults to the current working directory.
--json Emit structured JSON to stdout. Useful in CI and agentic lifecycle hooks.
--help, -h, help, h Print CLI usage.

Configuration

Create klint.yaml at the root of your project:

include: ["src"]
rules: {}
arch:
  layers:
    api: ["src/app/api/**"]
    db: ["src/app/db/**"]
    jobs: ["src/app/jobs/**"]

include controls which files are scanned. arch.layers gives names to file groups so rules can talk about architecture instead of repeating globs.

Import Boundaries

Use arch.imports to block dependencies between layers.

include: ["src"]
rules: {}
arch:
  layers:
    api: ["src/app/api/**"]
    db: ["src/app/db/**"]
  imports:
    - from: api
      deny: db
      message: "API code must not import database internals directly"

This flags Python imports such as:

from app.db.session import get_session

from files under src/app/api/**.

Forbidden Patterns

Use arch.forbidden to block text patterns inside a layer.

include: ["src"]
rules: {}
arch:
  layers:
    jobs: ["src/app/jobs/**"]
  forbidden:
    - in: jobs
      pattern: "print("
      message: "Jobs must not print directly"

This is useful for project-specific policies such as blocking direct logging, environment access, framework shortcuts, or unsafe helpers in the wrong layer.

Singleton Ownership

Use arch.singleton when a symbol or pattern must only appear in one file.

include: ["src"]
rules: {}
arch:
  singleton:
    - only: "src/app/config/settings.py"
      pattern: "API_KEY"
      message: "API_KEY must only live in settings.py"

This allows API_KEY in src/app/config/settings.py and flags the same pattern anywhere else in scanned files.

Supported Python Rules

The Python package currently supports:

  • arch/imports
  • arch/forbidden
  • arch/singleton

These rules are intentionally configuration-driven. They are for enforcing your project's architecture, not for replacing formatters or style linters.

CI

Run klint in CI after installing your Python dependencies:

pip install klint
klint --json

klint exits with:

  • 0 when no errors are found
  • 2 when rule violations are found
  • 1 for configuration or runtime errors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

klint-0.1.1-py3-none-win_amd64.whl (752.1 kB view details)

Uploaded Python 3Windows x86-64

klint-0.1.1-py3-none-manylinux_2_28_x86_64.whl (944.2 kB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

klint-0.1.1-py3-none-macosx_11_0_arm64.whl (875.9 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

klint-0.1.1-py3-none-macosx_10_13_x86_64.whl (889.3 kB view details)

Uploaded Python 3macOS 10.13+ x86-64

File details

Details for the file klint-0.1.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: klint-0.1.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 752.1 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for klint-0.1.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 77d200de15bcf3a9b84dabb0d70c5f5bbea1f2b98515759f8b6763ad6407a114
MD5 f4e1a7ac4bd6a76a866f1958b671c026
BLAKE2b-256 7073d5c230867a50b24f3a12370346a340985712ce334ca4efcf1ef1acb6aca1

See more details on using hashes here.

Provenance

The following attestation bundles were made for klint-0.1.1-py3-none-win_amd64.whl:

Publisher: python-release.yml on konvert7/klint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klint-0.1.1-py3-none-manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: klint-0.1.1-py3-none-manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 944.2 kB
  • Tags: Python 3, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for klint-0.1.1-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 edddeb3627d660f3410b327396546a53b2d1416a4ed4987201b5f74270877d75
MD5 aa7339cff372cb4af1c4adc3c28e0cf1
BLAKE2b-256 d2c9b4173b06fc3d9dce04219e67cb791a346abdda964526abd3279099f0b5a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for klint-0.1.1-py3-none-manylinux_2_28_x86_64.whl:

Publisher: python-release.yml on konvert7/klint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klint-0.1.1-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: klint-0.1.1-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 875.9 kB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for klint-0.1.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c844c2592857efba4dd9b7c60228d4cee78ca8c11d9021f812619d4828d13e80
MD5 72615cdcd0697616d885ab71e214665b
BLAKE2b-256 f4f0778a084511eb7c6167b15fb675392289cd8acb5ff72e028208b6a26d816c

See more details on using hashes here.

Provenance

The following attestation bundles were made for klint-0.1.1-py3-none-macosx_11_0_arm64.whl:

Publisher: python-release.yml on konvert7/klint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klint-0.1.1-py3-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for klint-0.1.1-py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 41b38540dc1464d4d63c9fca8f5d67bb2c5878ca100003cca98c4e1025671615
MD5 baed1d23cef63419075b3cd8b38f1999
BLAKE2b-256 aa520a93447dceb1dae411451e9de534b519ae37152e2b4977eeb96c73962cec

See more details on using hashes here.

Provenance

The following attestation bundles were made for klint-0.1.1-py3-none-macosx_10_13_x86_64.whl:

Publisher: python-release.yml on konvert7/klint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page