CLI guardrail for catching stale Python APIs before runtime.
Project description
llm-code-validator
Python CLI for detecting stale or version-incompatible third-party API usage in Python source code.
Installation
Install from the repository:
git clone https://github.com/mathew-felix/llm-code-validator
cd llm-code-validator
pip install -e .
Install with test dependencies:
pip install -e ".[dev]"
After the package is published to PyPI:
pip install llm-code-validator
Usage
Check one file:
llm-code-validator check file.py
Check a directory:
llm-code-validator check src/
Check standard input:
llm-code-validator check - < snippet.py
Check staged Git files:
llm-code-validator check --staged
Use an explicit dependency file:
llm-code-validator check --requirements requirements.txt src/
Show low-confidence diagnostics:
llm-code-validator check --show-low-confidence src/
Exit codes:
0: no diagnostics1: diagnostics found2: tool error
Output
Text output:
llm-code-validator check src/
JSON output:
llm-code-validator check src/ --format json
GitHub Actions annotation output:
llm-code-validator check src/ --format github
Fixes
Preview fixes:
llm-code-validator fix file.py
Apply safe fixes:
llm-code-validator fix file.py --write
Only rules marked safe_fix are written. Rules marked suggested_fix or no_fix are reported but not changed.
Current rule safety counts:
safe_fix: 15 rulessuggested_fix: 51 rulesno_fix: 2 rules
Signature Database
Validate the rule database:
llm-code-validator validate-signatures
The source rule database is:
data/library_signatures.json
The packaged rule database is:
llm_code_validator/library_signatures.json
Current rule count:
- 68 API-drift rules
Benchmarks
Run the CLI benchmark dataset:
python -m llm_code_validator.benchmark --dataset validation_dataset/cli_benchmark_cases.json
Run the AI-stack benchmark dataset:
python -m llm_code_validator.benchmark --dataset validation_dataset/ai_stack_benchmark_cases.json
Current saved benchmark results:
- CLI dataset: precision
1.0, recall1.0, p500.243ms, p956.199ms - AI-stack dataset: precision
1.0, recall1.0, p500.444ms, p954.939ms
Pre-Commit
.pre-commit-hooks.yaml is included:
repos:
- repo: https://github.com/mathew-felix/llm-code-validator
rev: v0.1.0
hooks:
- id: llm-code-validator
GitHub Actions
Example workflow:
name: API Drift Check
on:
pull_request:
jobs:
api-drift:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install llm-code-validator
- run: llm-code-validator check . --format github
Testing
Run the test suite:
pytest -q
Current local result:
72 passed
Documentation
docs/demo.md: example check and fix workflowdocs/rules.md: rule database notesdocs/release.md: package release stepsPROJECT_REPORT.md: project report
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_code_validator-0.1.0.tar.gz.
File metadata
- Download URL: llm_code_validator-0.1.0.tar.gz
- Upload date:
- Size: 28.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4e905bbb9746080038e7a91f4fd83fc866c36d0a943d777451cc8fa4cf8591b
|
|
| MD5 |
ec2b2e1687048825f702bc2b97d284cb
|
|
| BLAKE2b-256 |
8bc3f22fd93fe7f2df8fef93c3296809ae352daf9104ea690db9d7d4233c2d5b
|
File details
Details for the file llm_code_validator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: llm_code_validator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d541066a85b9a0df8d0c9d341a40e204885d6102a5d2942b31e5cae7e09775eb
|
|
| MD5 |
4f0164217fc0092869e1a612d66a5a08
|
|
| BLAKE2b-256 |
46f7cbf00d55c7dd3a92720328968ef73638ace8650ffe5477afd628e38efac9
|