Skip to main content

A Rust-powered checker for Python functions that violate functional-programming-oriented rules

Project description

fp-checker

fp-checker is a Rust-powered checker for Python codebases that reports functions which violate functional-programming-oriented rules. It provides both a CLI and a Python API, and can output results in text, JSON, or SARIF. In addition to built-in rules, you can add custom rules through configuration only.

English Summary

  • What it does: checks Python functions for side effects, hidden mutation, non-determinism, deprecated APIs, and other patterns that make code less functional
  • Interfaces: CLI and Python API
  • Output formats: text, json, sarif
  • Extensibility: built-in rules plus config-driven custom rules
  • Package: pip install fp-checker

Where To Start

日本語

Python コードを解析し、関数型プログラミングのルールに反した関数を検査する Rust 製ツールです。CLI と Python API の両方を提供し、結果は text / JSON / SARIF の各形式で出力できます。組み込みルールに加えて、設定ファイルだけで custom rule を追加できます。

どこを見れば何が分かるか

現在の実装範囲

  • Rust workspace: fp_checker_core, fp_checker_cli, fp_checker_py
  • Python 構文解析: rustpython-parser ベースの adapter
  • ignore デコレータ: @fp_ignore を既定値としてサポート
  • MVP ルール:
    • 可変グローバル状態
    • 代入の多用
    • 直接 I/O
    • 非決定的呼び出し
    • 外部状態への副作用
    • ミュータブルなデフォルト引数
    • 直接的な effectful call
    • global / nonlocal
  • 追加ルール:
    • hidden mutation
    • loop 内副作用
    • 例外制御フロー
    • class method 内副作用
    • 参照透過性を壊す暗黙依存
    • 非推奨 API 使用
  • 出力形式: text / JSON / SARIF
  • AI 向けの structured fix_hint を JSON に含める
  • CLI / Python API / pyproject.toml 設定対応
  • 設定スキーマ: unknown key を reject する strict TOML
  • config 駆動の custom rule: call / name / attribute_write
  • CI 上の Python smoke test: 3.9 / 3.10 / 3.11 / 3.12
  • JSON schema 検証: tests/fixtures/report.schema.json
  • リリース自動化: tag push で GitHub Release と PyPI publish
  • benchmark: cargo bench -p fp_checker_core
  • pre-commit: .pre-commit-config.yaml

クイックスタート

PyPI からインストール

pip install fp-checker
fp-checker --help
fp-checker check path/to/project
python -m fp_checker --help

CLI

cargo run -p fp_checker_cli -- check tests/fixtures/sample_project
cargo run -p fp_checker_cli -- check tests/fixtures/sample_project --format json
cargo run -p fp_checker_cli -- check tests/fixtures/sample_project --format sarif

Python API

maturin develop --manifest-path crates/fp_checker_py/Cargo.toml
python3 -c "import fp_checker; print(fp_checker.available_rules())"
import fp_checker

print(fp_checker.check_code("def f(items=[]):\n    return items", format="json"))

開発コマンド

cargo check
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test

リポジトリ構成

.
├── crates/
│   ├── fp_checker_cli/
│   ├── fp_checker_core/
│   └── fp_checker_py/
├── docs/
├── python/
│   └── examples/
├── tests/
│   └── fixtures/
├── .devcontainer/
├── .github/
│   ├── dependabot.yml
│   └── workflows/
├── Cargo.toml
├── pyproject.toml
├── CONTRIBUTING.md
├── SECURITY.md
└── CHANGELOG.md

Project details


Download files

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

Source Distribution

fp_checker-0.1.4.tar.gz (46.5 kB view details)

Uploaded Source

Built Distributions

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

fp_checker-0.1.4-cp39-abi3-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.9+Windows x86-64

fp_checker-0.1.4-cp39-abi3-manylinux_2_34_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ x86-64

fp_checker-0.1.4-cp39-abi3-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file fp_checker-0.1.4.tar.gz.

File metadata

  • Download URL: fp_checker-0.1.4.tar.gz
  • Upload date:
  • Size: 46.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fp_checker-0.1.4.tar.gz
Algorithm Hash digest
SHA256 61b09b3dd336efbeecac3651e719c4832fc086151b1a0de76f831beeee4afb9c
MD5 357eb3b8af56647fffc55573441bb3ba
BLAKE2b-256 1c369c9679e55d131ecd9dcc9eb169dba191b4544e4ec4923c1469c3fbf52c8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for fp_checker-0.1.4.tar.gz:

Publisher: release.yml on sotanengel/python-fp-checker

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

File details

Details for the file fp_checker-0.1.4-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: fp_checker-0.1.4-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fp_checker-0.1.4-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b46377b7b6769f94ed67a7dae98c9b8d21b50e58e1b7fd272a7a545073ef3e72
MD5 af148624d28340941ca8901d0f143952
BLAKE2b-256 f946d0a86cc59e61eb8e72671254c146de5c34b4470e806924eeaecf9d31e1eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for fp_checker-0.1.4-cp39-abi3-win_amd64.whl:

Publisher: release.yml on sotanengel/python-fp-checker

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

File details

Details for the file fp_checker-0.1.4-cp39-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for fp_checker-0.1.4-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 58ddac623595d220761790fb117365a9135ebe576fce6ca3a785b626f66ec421
MD5 6995aaac22b69c7c8de8d987cef388e4
BLAKE2b-256 6e61f6f077dbcaec27cd153be024ed0938ae65bc2f918f532648df558f5ad62a

See more details on using hashes here.

Provenance

The following attestation bundles were made for fp_checker-0.1.4-cp39-abi3-manylinux_2_34_x86_64.whl:

Publisher: release.yml on sotanengel/python-fp-checker

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

File details

Details for the file fp_checker-0.1.4-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fp_checker-0.1.4-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 16938289dbcbce611550f1fa61b5381a1c1360d48f354b760c105ef7f23514dc
MD5 27b083b567a67ae82d94e2858b44413f
BLAKE2b-256 4d62c403c383a7006582c964ba14fb73f1e7bb264f2092fd302451129d1d2a3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for fp_checker-0.1.4-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on sotanengel/python-fp-checker

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