Skip to main content

thai-lint

License: MIT Python 3.11+ PyPI Tests Coverage Documentation

The AI Linter - Catch the mistakes AI coding assistants keep making.

thailint detects anti-patterns that AI tools frequently introduce: duplicate code, excessive nesting, magic numbers, SRP violations, and more. It works across Python, TypeScript, JavaScript, and Rust with unified rules - filling gaps that existing linters miss.

Installation

pip install thailint

Or run instantly with uvx (no install required):

uvx thailint dry src/

Or with Docker:

docker run --rm -v $(pwd):/data washad/thailint:latest --help

Quick Start

# Generate a config file (optional)
thailint init-config

# Run any linter
thailint dry src/

That's it. See violations, fix them, ship better code.

Available Linters

Linter What It Catches Command Docs
DRY Duplicate code across files thailint dry src/ Guide
Nesting Deeply nested if/for/while blocks thailint nesting src/ Guide
Magic Numbers Unnamed numeric literals thailint magic-numbers src/ Guide
Performance O(n²) patterns: string += in loops, regex in loops thailint perf src/ Guide
SRP Classes doing too much thailint srp src/ Guide
File Header Missing documentation headers thailint file-header src/ Guide
Stateless Class Classes that should be functions thailint stateless-class src/ Guide
Collection Pipeline Loops with embedded filtering thailint pipeline src/ Guide
Method Property Methods that should be @property thailint method-property src/ Guide
File Placement Files in wrong directories thailint file-placement src/ Guide
Lazy Ignores Unjustified linting suppressions thailint lazy-ignores src/ Guide
Improper Logging Print statements and conditional verbose patterns thailint improper-logging src/ Guide
Stringly Typed Strings that should be enums thailint stringly-typed src/ Guide
LBYL Look Before You Leap anti-patterns thailint lbyl src/ Guide
Law of Demeter Deep object chain access (reaching through objects) thailint law-of-demeter src/ Guide
Version Freshness EOL/outdated runtime versions in infra files thailint version-freshness . Guide
Unwrap Abuse .unwrap()/.expect() that panic at runtime (Rust) thailint unwrap-abuse src/ Guide
Clone Abuse .clone() abuse: loops, chains, unnecessary (Rust) thailint clone-abuse src/ Guide
Blocking Async Blocking std:: calls in async functions (Rust) thailint blocking-async src/ Guide

Configuration

Create .thailint.yaml in your project root:

dry:
  enabled: true
  min_duplicate_lines: 4

nesting:
  enabled: true
  max_nesting_depth: 3

magic-numbers:
  enabled: true
  allowed_numbers: [-1, 0, 1, 2, 10, 100]

Or add a [tool.thailint] section to your pyproject.toml:

[tool.thailint]
dry = {enabled = true, min_duplicate_lines = 4}
nesting = {enabled = true, max_nesting_depth = 3}
magic-numbers = {enabled = true, allowed_numbers = [-1, 0, 1, 2, 10, 100]}

Config precedence: .thailint.yaml > .thailint.json > pyproject.toml.

Or generate one automatically:

thailint init-config --preset lenient  # or: strict, standard

See Configuration Reference for all options.

Output Formats

# Human-readable (default)
thailint dry src/

# JSON for CI/CD
thailint dry --format json src/

# SARIF for GitHub Code Scanning
thailint dry --format sarif src/ > results.sarif

Ignoring Violations

# Line-level
timeout = 3600  # thailint: ignore[magic-numbers]

# File-level
# thailint: ignore-file[dry]

Or in config:

dry:
  ignore:
    - "tests/"
    - "**/generated/**"

See How to Ignore Violations for all 5 ignore levels.

CI/CD Integration

# GitHub Actions
- name: Run thailint
  run: |
    pip install thailint
    thailint --parallel dry src/
    thailint --parallel nesting src/

Use --parallel for faster linting on large codebases (2-4x speedup on multi-core systems).

Exit codes: 0 = success, 1 = violations found, 2 = error.

Documentation

Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

git clone https://github.com/be-wise-be-kind/thai-lint.git
cd thai-lint
poetry install
just test

License

MIT License - see LICENSE for details.

Support

Metadata

Release files for thailint 0.25.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thailint 0.25.1
File Size Uploaded Provenance Actions
thailint-0.25.1.tar.gz 348.1 kB Without provenance Details for thailint-0.25.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for thailint 0.25.1
File Interpreter ABI Platform Actions
thailint-0.25.1-py3-none-any.whl Python 3 none any Details for thailint-0.25.1-py3-none-any.whl

Total release size: 844.2 kB

Release files / thailint-0.25.1.tar.gz

Download URL thailint-0.25.1.tar.gz
Size 348.1 kB
Tags Source
SHA-256 checksum
How to use checksums
55c55ad2925260b2c5c10afdc7b35054395f877d3f032bc8608539297e9c2771
BLAKE2b-256 checksum
How to use checksums
438da40f031a4481ab86610ba0cccd2deaa56dc5c6487b6064c0a46678050918
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.3 Linux/6.18.7-76061807-generic

Release files / thailint-0.25.1-py3-none-any.whl

Download URL thailint-0.25.1-py3-none-any.whl
Size 496.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d635d0e943ff94846d42a7021a5f924d35190b4b75778241eba8ffd33c8b5ee0
BLAKE2b-256 checksum
How to use checksums
c3ac3e0e17145db751c36f7c3249422ca3b114916bdd2700a6b253063592c4b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.3 Linux/6.18.7-76061807-generic

Security for thailint 0.25.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.25.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page