Metadata-Version: 2.4
Name: req-pincheck
Version: 0.1.0
Summary: Lint requirements.txt files for unpinned or loosely pinned dependencies, with CI-friendly exit codes.
License-Expression: MIT
Keywords: requirements,pip,pinning,dependencies,lint,ci,reproducibility
Classifier: Programming Language :: Python :: 3
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Build Tools
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: packaging>=22
Dynamic: license-file

# req-pincheck

Reproducible builds die quietly when someone adds `requests` (no version) or
`django>=4` to a requirements file. `req-pincheck` lints `requirements*.txt`
files and fails CI when dependencies aren't pinned to the level you require.

## Install

```bash
pip install req-pincheck
```

## Usage

```bash
req-pincheck requirements.txt                 # every dep must be pinned with == (default)
req-pincheck --level bounded requirements.txt # allow ranges, but require an upper bound (<, <=, ~=, ==)
req-pincheck --level any requirements.txt     # just require *some* version specifier
req-pincheck --ignore pip --ignore setuptools requirements*.txt
req-pincheck --json requirements.txt
```

Example output:

```
requirements.txt:3: requests — unpinned (no version specifier)
requirements.txt:5: django>=4.2 — not an exact pin (needs ==)
requirements.txt:9: numpy==1.* — wildcard pin (needs exact version)
3 problem(s) in 1 file(s)
```

### Levels

| level     | passes                         | fails                      |
|-----------|--------------------------------|----------------------------|
| `exact`   | `==1.2.3`, `===1.2.3`          | everything else            |
| `bounded` | `==`, `~=`, anything with `<`/`<=` | `>=1.0`, `!=1.1`, no spec |
| `any`     | any specifier                  | no specifier               |

### What it understands

- `-r other.txt` / `--requirement` includes (followed recursively, relative to the including file) and `-c` constraint files
- Environment markers (`foo==1.0; python_version < "3.10"`)
- Extras (`uvicorn[standard]==0.30.0`)
- Line continuations and `--hash=...` options
- Comments, blank lines and pip options (`--index-url`, etc.) are skipped
- Direct references (`pkg @ https://...`, `git+https://...`, local paths, `-e`) are reported as
  `unversioned-url` — use `--allow-urls` to accept them
- Add `# pincheck: ignore` to a line to skip it

### Exit codes

| code | meaning |
|------|---------|
| 0    | everything pinned |
| 1    | at least one problem |
| 2    | a file could not be read |

## Python API

```python
from req_pincheck import check_file

for problem in check_file("requirements.txt", level="bounded"):
    print(problem.path, problem.line, problem.name, problem.reason)
```

## License

MIT
