findfmt Documentation

findfmt Logo

PyPI Version Python Versions PyPI Wheel PyPI Status PyPI Downloads GitHub Release GHCR Container Platforms Hatch

CI Status Dependency Matrix Docs Build Vale Prose Lint pre-commit.ci status Last Commit

Coverage uv Ruff ty Docstring Coverage: 100% Tested with Hypothesis PEP 561 Typed Deptry Vulture Xenon Codespell PyMarkdown

CodeQL zizmor ClusterFuzzLite GitGuardian Dependabot OpenSSF Scorecard OpenSSF Best Practices SLSA Provenance Security Policy

Documentation i18n Languages License: MIT Semantic Versioning Conventional Commits Keep a Changelog Accessibility WCAG 2.1 AA Pull Requests Welcome GitHub Issues GitHub Stars

findfmt is a high-performance, .gitignore-aware file discovery and classification suite. It locates files by content format, shebang, and MIME tag rather than relying strictly on file extensions.

1. Core Capabilities

  • Intelligent Classification: Powered by the identify engine and content heuristics to identify file types (e.g. Python, Shell, YAML, JSON, Executable) even when filenames lack extensions.

  • Git-Aware Traversal: Automatically prunes directories and files matched by .gitignore and .git/info/exclude rules early in traversal.

  • Deterministic Output: Always produces clean, relative, alphabetically sorted file paths ready for Unix pipelines and xargs.

  • Hybrid Python-Rust Architecture: Built with a strict uv-first methodology, PyO3 abi3-py311 native extension support (findfmt._rust_ext), guaranteed pure-Python fallback (FINDFMT_NO_EXTENSIONS=1), 100% test coverage, and strict static type checking.

2. Quickstart

2.1. Direct Execution & Installation

Execute immediately with uvx without an explicit installation step:

uvx findfmt --help
uvx findfmt -t python

Install as an isolated user tool or project dependency:

# Global tool installation via uv
uv tool install findfmt

# Add to managed Python project
uv add findfmt

# Standard pip installation
pip install findfmt

2.2. Core Discovery Workflows

# Locate all Python files
findfmt -t python

# Locate files matching either Python or Shell scripts
findfmt -t python,shell

# Discover executable scripts by shebang pattern
findfmt --shebang bash

# Filter by glob pattern while honoring .gitignore
findfmt -P "*.py|*.md"

# Safe piping with NUL delimiters for xargs
findfmt -t python -0 | xargs -0 ruff format

2.3. Programmatic Python Library Usage

Integrate findfmt directly into Python scripts and automated pipelines:

from findfmt import FileInfo, TraversalConfig, find_files, get_formatter

# Configure traversal scope and format filtering
config = TraversalConfig(include_tags={"python"}, root_paths=["src"])

# Iterate through discovered FileInfo objects
for file_info in find_files(config):
    print(f"{file_info.path} ({file_info.size_bytes} bytes)")

# Format output using any built-in serializer (e.g. table, json, tree)
formatter = get_formatter("table")
print(formatter.format(find_files(config)))

User Guide

API Documentation

Community & Governance


3. Community & Feedback